Tutorials › Graph Theory (Undergraduate) › Running Time And Parallel Rounds In Boruvka’s Algorithm

Minimum Spanning Trees · Tutorial 148 of 799

Running Time And Parallel Rounds In Boruvka's Algorithm

Learn why Borůvka’s algorithm finishes in logarithmically many rounds and how repeated edge scans determine its running time.

Intermediate 9 min read

What You'll Learn

  • Define a Borůvka round as simultaneous minimum-outgoing-edge choices followed by merges.
  • Prove that each connected round reduces the number of components by at least half.
  • Derive the round bound from the number of vertices or current components.
  • Count repeated full scans and component-merging work.
  • Distinguish all chosen edges from the successful-union edges retained in the output tree.

Rounds as Simultaneous Component Merges

Borůvka’s algorithm builds a minimum spanning tree by repeatedly joining current components. Its useful feature for analysing running time is that a round makes progress everywhere at once: each component that has an edge leaving it chooses a least-weight such edge. The choices are made using the components as they stood at the start of the round, and then the chosen edges are processed to merge components.

Throughout, let \(G=(V,E)\) be a finite, connected, simple, undirected graph with edge weights. Write \(n=|V|\) and \(m=|E|\). Ties between equally light outgoing edges may be resolved by any fixed rule. A current component is a connected component of the forest formed by the edges retained so far. An edge is outgoing from a current component if exactly one of its endpoints belongs to that component.

Definition: In one Borůvka round, every current component chooses one minimum-weight outgoing edge, if it has one. All choices are made before the merges of that round. The chosen edges are then processed, merging the components they connect. An edge is retained in the output forest only if its endpoints are not already connected there.

When more than one current component remains in a connected graph, each has an outgoing edge: a path from a vertex in that component to a vertex outside it must use an edge leaving it. If only one component remains, the algorithm stops. The earlier correctness result for Borůvka’s algorithm establishes that the chosen minimum outgoing edges can be used to build a minimum spanning tree. Here the focus is how quickly the components merge and how much work the rounds require.

Why the Component Count Is Halved

Theorem: Suppose a connected graph has \(c>1\) current components at the start of a Borůvka round. After all that round’s chosen edges have been merged, the number of current components is at most \(\lfloor c/2\rfloor\).

Proof. Make an auxiliary graph whose vertices are the \(c\) current components, with two such vertices adjacent when at least one edge chosen in the round joins the corresponding components. Every current component chooses an outgoing edge, so every vertex of this auxiliary graph is incident with at least one chosen edge. Consequently, each connected component of the auxiliary graph contains at least two vertices. If the auxiliary graph has \(q\) connected components, its \(q\) vertex sets are disjoint, each of size at least two, and together contain all \(c\) vertices. Thus \(2q\le c\), so \(q\le\lfloor c/2\rfloor\). Merging the chosen edges makes exactly the vertices in each auxiliary connected component part of one new current component. Therefore the new component count is \(q\), which is at most \(\lfloor c/2\rfloor\). \(\square\)

This argument does not require the chosen edges to form a forest. Several choices can lead to a cycle among current components. What matters for halving is that no current component is isolated in the auxiliary graph: it chose an outgoing edge.

Corollary: Starting with \(n\ge 1\) vertices in a connected graph, Borůvka’s algorithm needs at most \(\lceil\log_2 n\rceil\) rounds. More generally, if it starts with \(c_0\ge1\) current components, it needs at most \(\lceil\log_2 c_0\rceil\) rounds.

Proof. If \(c_i\) is the number of components after \(i\) rounds, the theorem gives \(c_{i+1}\le c_i/2\) whenever \(c_i>1\). Hence, by induction, \(c_i\le c_0/2^i\): it holds at \(i=0\), and \(c_{i+1}\le c_i/2\le c_0/2^{i+1}\) proves the next case. For \(i=\lceil\log_2 c_0\rceil\), we have \(2^i\ge c_0\), so \(c_i\le1\). Since the graph is connected and at least one vertex is present, the process has reached one component. If \(c_0=1\), it requires zero rounds, consistent with \(\lceil\log_2 1\rceil=0\). \(\square\)

The bound concerns the number of rounds, not a guarantee that every round halves the count exactly. Some rounds merge many components at once. If the input graph is disconnected and the goal is a minimum spanning forest, apply the argument separately inside each original connected component. In that setting, finished components do not participate in later rounds, so the total number of components across the whole graph need not halve each time. The number of rounds is bounded by the largest number of vertices in any original connected component.

Worked Example: Eight Vertices and Three Rounds

Let \(V=\{1,2,3,4,5,6,7,8\}\), and let \(E=\{12,23,34,45,56,67,78\}\). Give the edges weights \(w(12)=1\), \(w(23)=2\), \(w(34)=1\), \(w(45)=3\), \(w(56)=1\), \(w(67)=2\), and \(w(78)=1\). The graph is connected and has \(n=8\) vertices and \(m=7\) edges.

Round 1. Initially each vertex is its own component. The minimum outgoing choices are \(12\) from vertices 1 and 2, \(34\) from 3 and 4, \(56\) from 5 and 6, and \(78\) from 7 and 8. Thus the new components are \(\{1,2\},\{3,4\},\{5,6\},\{7,8\}\): the count is \(8\to4\).

Round 2. Between \(\{1,2\}\) and \(\{3,4\}\), the outgoing edge is \(23\), of weight 2. Between \(\{3,4\}\) and \(\{5,6\}\), the edge is \(45\), of weight 3. Between \(\{5,6\}\) and \(\{7,8\}\), the edge is \(67\), of weight 2. The first component chooses \(23\); the second chooses \(23\) rather than \(45\); the third chooses \(67\) rather than \(45\); and the fourth chooses \(67\). The resulting components are \(\{1,2,3,4\}\) and \(\{5,6,7,8\}\): the count is \(4\to2\).

Round 3. The only edge between those two components is \(45\), so it is chosen and merged. The count is \(2\to1\), and the algorithm stops. The observed sequence is \(8,4,2,1\), which reaches the bound \(\lceil\log_2 8\rceil=3\).

Check: The three rounds inspect all \(m=7\) edges each, for \(3\cdot7=21\) edge inspections. The retained edges are \(12,34,56,78,23,67,45\), all seven edges of the input graph. They connect all eight vertices, and there are \(7=8-1\) of them.

Counting the Work of Edge Scans

A standard simple implementation scans the entire edge set in every round. During a scan, it compares the current component labels at the two endpoints of each edge. If the labels differ, the edge is outgoing from both endpoint components; the scan updates the best (least-weight) outgoing edge recorded for each of them. Each edge is inspected once in that scan, so the edge-inspection work is \(O(m)\) per round.

For a precise total bound, component labels can be maintained using lists of vertices for each component. When chosen edges are processed, merge components by relabelling the smaller component’s vertices and joining its list to the larger list. Whenever a vertex is relabelled, the size of its component at least doubles: it was in the smaller component, and the new component contains both the smaller and the larger one. A vertex can therefore be relabelled at most \(\lfloor\log_2 n\rfloor\) times. Across the algorithm, this costs \(O(n\log n)\); initializing labels and recording each round’s minima costs \(O(n)\) per round.

The number of rounds \(R\) is at most \(\lceil\log_2 n\rceil\). Thus full edge scans cost \(O(mR)=O(m\log n)\), while initialization and per-round vertex work cost \(O(n\log n)\). Since a connected graph on \(n\ge2\) vertices has \(m\ge n-1\), the total is \(O(m\log n)\). The one-vertex graph needs no scan and no round. This is a bound for an implementation that makes one full scan per round; an implementation that performs additional data-structure operations must count those operations as well.

Each component chooses one edge in a round, so there are at most \(c_i\) choice occurrences in round \(i\), counting an edge twice if both its endpoint components choose it. From the halving bound, the total number of choice occurrences is less than \(2n\): the component counts are bounded by \(n,n/2,n/4,\ldots\), whose finite geometric sum is less than \(2n\). Processing these occurrences is therefore linear in \(n\), apart from the cost of updating component membership described above.

Worked Example: A Star Merges in One Round

Let \(V=\{0,1,2,3,4\}\) and \(E=\{01,02,03,04\}\), with weights \(w(01)=1\), \(w(02)=2\), \(w(03)=3\), and \(w(04)=4\). Initially there are five components. The center 0 chooses \(01\), its lightest outgoing edge. Each leaf has only one incident edge, so leaves 1, 2, 3, and 4 choose \(01,02,03,\) and \(04\), respectively.

All four edges are selected, and after the round they connect all five vertices. The component count is \(5\to1\), which is at most \(\lfloor5/2\rfloor=2\). This single round scans \(m=4\) edges once, so it performs four edge inspections.

Check: The retained edges are \(01,02,03,04\). They connect every vertex to 0, and their number is \(4=5-1\); the output is a spanning tree.

Chosen Edges Are Not the Same as Retained Edges

Component choices are made independently. In particular, an edge chosen by one component may also be chosen by another, and processing choices can encounter an edge whose endpoints have already been joined by earlier choices in the same round. A correct implementation checks whether each chosen edge joins distinct output components before retaining it. A successful merge adds one edge; a choice that would create a cycle is discarded.

Worked Example: Three Choices Around a Triangle

Let \(V=\{1,2,3\}\), \(E=\{12,23,13\}\), and give every edge weight 1. Resolve ties so that component 1 chooses \(12\), component 2 chooses \(23\), and component 3 chooses \(13\). Initially there are three singleton components, and all three distinct edges are selected in the one round.

Process the choices in the order \(12,23,13\). Edge \(12\) joins two separate output components, so retain it. Edge \(23\) also joins separate output components, so retain it. After these two merges, vertices 1, 2, and 3 are already connected. Edge \(13\) therefore fails the separate-components test and is discarded. The round leaves one component and retains two edges.

Check: The retained set \(\{12,23\}\) connects all three vertices and has \(2=3-1\) edges. The selected set has three distinct edges, so the assertion that at most \(n-1\) distinct edges are selected would be false here; the \(n-1\) bound applies to successful merges retained in the output tree.

Common Pitfalls and What the Bound Says

Confusing selected edges with successful merges. In the triangle example, three distinct edges are selected even though \(n-1=2\). The correction is to distinguish the list of component choices from the edges accepted into the output forest: each successful union adds one retained edge, and the final spanning tree has \(n-1\) retained edges.

Counting only one scan. A scan finds the current minimum outgoing edges, but those minima can change after components merge. The stated implementation makes a fresh full scan in every round. If there are \(R\) rounds, the edge-inspection count is \(mR\), not just \(m\).

Misreading the halving bound. The theorem says the new count is at most \(\lfloor c/2\rfloor\), not that it is exactly half. The star example drops from five components to one. The logarithmic bound follows because repeated halving is an upper bound on how long the process can take; it does not predict the exact number of rounds for every graph.

Thus Borůvka’s algorithm has two useful measures of progress. Each round cuts the current component count by at least a factor of two, giving at most \(\lceil\log_2 n\rceil\) rounds on a connected graph. A full edge scan costs \(O(m)\), giving \(O(m\log n)\) edge-scan work overall, with component maintenance accounted for separately.

Check Your Understanding

Use the definitions and bounds above to answer the following questions.

  1. A connected graph starts a round with 11 current components. What is the largest possible number after the round, and what is the largest number of rounds needed from that state?
  2. Explain why every vertex of the auxiliary graph in the halving proof has degree at least one.
  3. A connected graph has \(n=32\) vertices and \(m=50\) edges. What upper bound does the round theorem give, and how many edge inspections does one full scan per round entail at that bound?
  4. Why can the number of distinct selected edges in one round exceed \(n-1\), while the number of retained edges in a spanning tree cannot?
  5. For a disconnected input, why should the round bound be applied separately to each original connected component?