Tutorials › Graph Theory (Undergraduate) › Boruvka’s Algorithm By Component Merging

Minimum Spanning Trees · Tutorial 146 of 799

Boruvka's Algorithm By Component Merging

See how simultaneous cheapest-edge choices merge components in Boruvka’s algorithm, with explicit traces, tie handling, and structural checks.

Intermediate 10 min read

What You'll Learn

  • Define a component’s outgoing edges and its cheapest-edge choice.
  • Trace simultaneous choices and merges across multiple rounds.
  • Use a fixed edge order to resolve equal-weight choices.
  • Check the components and selected edges after each round.
  • Recognize what changes when the input graph is disconnected.

The Component-Merging Idea

Prim’s algorithm grows one tree from a starting vertex, while Kruskal’s algorithm scans edges in weight order. Boruvka’s algorithm instead works on all current components at once: each component chooses a cheapest edge that leaves it, and the chosen edges are added simultaneously. The resulting connected groups become the components for the next round.

Throughout, an edge-weighted graph is a finite, simple graph \(G=(V,E)\) together with a real weight \(w(e)\) for each edge \(e\in E\). A spanning tree is a connected, acyclic subgraph containing every vertex. A minimum spanning tree is a spanning tree whose total edge weight is least among all spanning trees of the graph. The algorithm is usually applied to a connected graph; on a disconnected graph, the same steps produce a forest, one tree in each connected component.

Definition: For a current component \(C\subseteq V\), an edge \(uv\) is outgoing from \(C\) if exactly one of \(u,v\) lies in \(C\). The component’s cheapest outgoing edge is an outgoing edge of minimum weight. If several outgoing edges have equal minimum weight, choose one using a fixed total order on the edges. This order breaks ties only: an edge of lower weight takes priority over every edge of higher weight.

At the start, each vertex is its own component. In a round, every component with at least one outgoing edge chooses one cheapest outgoing edge, using the same fixed tie-breaking order throughout. Add the union of these chosen edges, counting an edge only once if both endpoint components choose it. Then take the connected components formed by the old components and the newly chosen edges. Repeat until no further merge is possible. For a connected input, the intended stopping state is a single component.

The word simultaneously matters. All choices in a round are made from the components as they stood at the beginning of that round. One does not update the components after each individual choice and then make later choices from those changed components.

What Happens in One Round

For a precise description of ties, assign the edges distinct ranks according to a fixed total order. Compare edges by the pair \((w(e),\operatorname{rank}(e))\), in lexicographic order: compare weights first, and compare ranks only when weights are equal. Every component chooses its least outgoing edge in this priority order. Since the graph is finite, a component with at least one outgoing edge has a choice.

1
Freeze the current partition.
Record the current components before making any choices. These are the components used throughout this round.
2
Choose outgoing edges.
For each component that has an outgoing edge, select one of minimum weight. Resolve equal weights by the fixed edge order.
3
Add the choices together.
Take the union of the chosen edges; if two components chose the same edge, include it only once.
4
Merge.
Within each group connected by the added edges, combine the old components into a new component.
Proposition: In any round, the selected edges, viewed between the current components, contain no cycle. The quotient may have parallel edges, so two distinct edges joining the same pair of components count as a cycle of length \(2\).

Proof. Form a quotient multigraph whose vertices are the current components and whose edges are the selected outgoing edges between them. There are no loops, since every selected edge is outgoing. Suppose this multigraph contains a cycle. Choose an edge \(e\) of greatest priority on that cycle, where priority is the lexicographic order by weight and fixed rank. The edge \(e\) was selected by at least one of its endpoint components; call one such component \(C\). The cycle has another edge \(f\) incident with \(C\). This edge is also outgoing from \(C\), and it is distinct from \(e\). Since \(e\) has greatest priority on the cycle, \(f\) has lower priority than \(e\). But \(C\) selected \(e\) as its least-priority outgoing edge, contradicting the availability of \(f\). Thus the quotient graph has no cycle. \(\square\)

This proposition concerns the edges selected in a single round, relative to the components at the start of that round. It does not by itself prove that the final tree has minimum total weight; the cut property and its exchange argument are the tools used to establish that optimality.

Worked Rounds

Worked Example: Four Components Merge in Two Rounds

Let \(G\) have vertex set \(V=\{1,2,3,4,5,6,7,8\}\) and edge set with weights \(w(12)=1\), \(w(34)=1\), \(w(56)=1\), \(w(78)=1\), \(w(23)=4\), \(w(45)=3\), \(w(67)=2\), \(w(13)=6\), \(w(24)=7\), \(w(36)=8\), and \(w(58)=9\). The graph is connected. Ties, if any, are resolved by a fixed edge order.

Initially every vertex is a component. The cheapest outgoing choices are \(12\) from component \(\{1\}\), \(12\) from \(\{2\}\), \(34\) from \(\{3\}\), \(34\) from \(\{4\}\), \(56\) from \(\{5\}\), \(56\) from \(\{6\}\), \(78\) from \(\{7\}\), and \(78\) from \(\{8\}\). For example, vertex \(3\) chooses \(34\), of weight \(1\), rather than \(23\), \(13\), or \(36\), of weights \(4\), \(6\), and \(8\). Removing duplicates gives the round-one edge set \(\{12,34,56,78\}\). The new components are \(\{1,2\}\), \(\{3,4\}\), \(\{5,6\}\), and \(\{7,8\}\).

In round two, component \(\{1,2\}\) has outgoing edges \(23\), \(13\), and \(24\), of weights \(4\), \(6\), and \(7\), so it chooses \(23\). Component \(\{3,4\}\) has outgoing edges \(23\), \(45\), \(24\), and \(36\), of weights \(4\), \(3\), \(7\), and \(8\), so it chooses \(45\). Component \(\{5,6\}\) chooses \(67\), of weight \(2\), rather than \(45\), of weight \(3\), or \(58\), of weight \(9\). Component \(\{7,8\}\) chooses \(67\), of weight \(2\), rather than \(58\), of weight \(9\). Thus the distinct round-two edges are \(\{23,45,67\}\), and all eight vertices are now in one component.

The chosen edges are \(12,34,56,78,23,45,67\). Their total weight is \(1+1+1+1+4+3+2=13\). They connect the vertices in the order \(1,2,3,4,5,6,7,8\), so they form a spanning path. As an independent check on the edge count, a path on eight vertices has seven edges, and the selected set has \(4+3=7\) edges. This trace illustrates Boruvka’s merges; the graph also has four extra edges, which were not selected.

Worked Example: Equal Weights and Duplicate Choices

Let \(G\) have vertex set \(V=\{a,b,c,d\}\) and edge set \(E=\{ab,ac,bc,cd,bd\}\), with weights \(w(ab)=1\), \(w(ac)=1\), \(w(bc)=2\), \(w(cd)=3\), and \(w(bd)=4\). Fix a total edge order in which \(ab\) precedes \(ac\).

At the start, the four components are single vertices. Vertex \(a\) has two cheapest outgoing edges, \(ab\) and \(ac\), both of weight \(1\), so it chooses \(ab\) by the fixed order. Vertex \(b\) chooses \(ab\), since its incident edge weights are \(1,2,4\). Vertex \(c\) chooses \(ac\), since its incident edge weights are \(1,2,3\). Vertex \(d\) chooses \(cd\), since its incident edge weights are \(3,4\). The union of the choices is \(\{ab,ac,cd\}\); \(ab\) appears twice among the choices but is added once.

These three edges connect all four vertices as the path \(b,a,c,d\). Their total weight is \(1+1+3=5\). The edge count is \(3\), which is the number of edges in this four-vertex path; the unselected edges \(bc\) and \(bd\) do not change the component formed in the round.

Worked Example: A Disconnected Input

Let \(G\) have vertex set \(V=\{1,2,3,4,5,6\}\) and edge set \(E=\{12,23,13,45\}\), with weights \(w(12)=2\), \(w(23)=5\), \(w(13)=7\), and \(w(45)=1\). Vertex \(6\) is isolated.

In the first round, vertex \(1\) chooses \(12\), because its incident edge weights are \(2\) and \(7\). Vertex \(2\) also chooses \(12\), since \(2<5\). Vertex \(3\) chooses \(23\), since \(5<7\). Vertices \(4\) and \(5\) both choose \(45\), and vertex \(6\) has no outgoing edge. After removing duplicate choices, the selected edges are \(\{12,23,45\}\). The resulting components are \(\{1,2,3\}\), \(\{4,5\}\), and \(\{6\}\).

The original graph has exactly these three connected components: the first contains edges \(12,23,13\), the second contains edge \(45\), and the third is the isolated vertex. No edge leaves any of them, so no further merge is possible. The selected forest has total weight \(2+5+1=8\). It has \(3\) edges on \(6\) vertices and \(3\) components; independently, each component is visibly a tree (including the one-vertex tree \(\{6\}\)). A disconnected input has no spanning tree, so here the output is a forest rather than a spanning tree.

Why the Component Description Is Consistent

Proposition: After a round, two vertices belong to the same new component exactly when their old components can be joined by a sequence of edges selected in that round.

Proof. Regard each old component as one vertex and each selected outgoing edge as an edge between the corresponding old components. By the definition of a connected component, two of these quotient vertices lie in the same connected component precisely when there is a sequence of quotient edges joining them. Replacing each quotient vertex by its old component gives exactly the groups formed by adding the selected edges to the old components. Thus two original vertices are in the same new component precisely when their old components are joined by such a sequence. \(\square\)

The proposition explains why simultaneous selections are easy to record: first list the old components, then the distinct chosen edges, then the groups connected by those edges. An edge selected by both endpoint components is still just one edge in the union. It does not create an extra merge or count twice toward the eventual tree.

Common Pitfalls

Using the tie order to compare different weights. Suppose a vertex \(a\) is incident with edges \(ab\) of weight \(1\) and \(ac\) of weight \(3\), and the fixed edge order puts \(ac\) before \(ab\). It is wrong to choose \(ac\) because it comes first in that order. The component chooses \(ab\), since \(1<3\); the fixed order is consulted only when the weights are equal.

Making choices sequentially within a round. If one component’s choice merges it with another component, that does not change the choices that other components make in that same round. Freeze the partition first, let every component choose from that partition, and only then merge.

Counting a mutual choice twice. If two components choose the same edge between them, the selected union contains one edge, not two. Likewise, when reporting a round’s merges, use the connected groups formed by all distinct selected edges rather than counting each component’s choice as a separate merge.

Check Your Understanding

For each question, state the current components before applying the round’s choices.

  1. In a connected graph with more than one current component, why must each component have at least one outgoing edge?
  2. Suppose a component has outgoing edges of weights \(2,2,5\). How does the fixed edge order affect its choice?
  3. In the four-vertex example, which components choose \(ab\), and how many copies of \(ab\) enter the selected union?
  4. Explain why choices in the second round of the eight-vertex example are made from four components rather than from eight single vertices.
  5. What does Boruvka’s procedure produce when the input graph has an isolated vertex and at least one other component?