A Bit of History
Otakar Borůvka published the method in 1926 while studying how to connect locations in Moravia with as little electrical wiring as possible. That physical design question is exactly a minimum spanning tree problem: connect every site, create no unnecessary cycle, and minimize total edge weight.
The algorithm predates the familiar Kruskal and Prim formulations by roughly three decades. Its oldest idea also feels unusually modern: do the same local computation for many components at once, then contract the results and repeat.
Problem and the Forest Invariant
Let $G=(V,E)$ be an undirected weighted graph. If $G$ is connected, the goal is a spanning tree with $|V|-1$ edges and minimum total weight. If $G$ is disconnected, no spanning tree exists; the natural output is a minimum spanning forest containing one minimum spanning tree for each connected region.
Borůvka never grows just one tree. It maintains a forest $F$ whose connected components are partial trees. Initially, $F$ has no edges, so every vertex is its own component. A phase chooses safe edges between these components and merges them. The invariant is:
At every phase boundary, the chosen edges form a forest that can still be extended to some minimum spanning forest.
No accepted cycle
Union–find rejects a proposed edge when its endpoints are already connected.
One local choice
Each component looks only for its lightest edge leading outside itself.
Many merges
After a phase, each merged tree behaves like one super-vertex in the next phase.
What Happens in One Borůvka Phase?
- Identify current components. A disjoint-set union structure gives each vertex a component representative.
- Scan every edge. Ignore internal edges. For each crossing edge $(u,v)$, offer it to the components containing $u$ and $v$.
- Keep one cheapest outgoing edge per component. A deterministic key such as $(w,\min(u,v),\max(u,v))$ makes ties reproducible.
- Process the selected edges. Add an edge only if union–find says it connects two components that are still different. This removes duplicate selections and prevents equal-weight tie cycles.
- Start the next phase. Stop when one component remains or when a phase performs no merge, which certifies that the input graph was disconnected.
The Right Mental Model
Prim asks one growing tree, “What is your cheapest escape?” Borůvka asks every tree in the current forest the same question simultaneously. Kruskal orders edges globally; Borůvka repeatedly summarizes them locally by component.
Visual Walkthrough
In the graph below, red and teal edges are the cheapest choices made by singleton components in phase 1. Two pairs select the same edge from opposite ends: both $A$ and $B$ choose $AB$, while both $D$ and $E$ choose $DE$. Deduplication leaves four useful edges.
Phase 2 now reasons about two components, not six vertices. Among the crossing edges $CD(5)$, $BD(8)$, $CE(9)$, and $BF(10)$, both components select $CD(5)$. One successful union completes the tree.
Why Is a Component's Cheapest Edge Safe?
Take one current component $C$. The cut $(C,V\setminus C)$ separates that tree from the rest of the graph. Its cheapest outgoing edge $e$ is a light edge across this cut. By the cut property, there is a minimum spanning forest compatible with the edges already accepted that also contains $e$.
The usual exchange argument makes this concrete. Start with a compatible optimum $T$. If $T$ already contains $e$, nothing changes. Otherwise adding $e$ creates a cycle. That cycle must contain another edge $f$ crossing the same cut. Since $e$ is cheapest, $w(e)\le w(f)$. Replacing $f$ by $e$ reconnects the tree without increasing its weight.
Ties Need One Extra Sentence
With equal weights, inconsistent local choices can nominate a cycle. A globally consistent key behaves like an infinitesimal perturbation of tied weights, while union–find remains the final cycle check. This makes the result reproducible; it does not require the MST itself to be unique.
Why Are There Only Logarithmically Many Phases?
Suppose a connected portion begins a phase with $c>1$ current components. Every component has at least one outgoing edge and therefore selects a neighbor. In the graph formed by selected component-to-component links, no component is isolated. Each merged group consequently contains at least two old components, so the next phase has at most $c/2$ components:
$$c_{i+1}\le \frac{c_i}{2}\qquad\Longrightarrow\qquad c_k\le \frac{|V|}{2^k}.$$
After at most $\lceil\log_2 |V|\rceil$ phases, each original connected region has collapsed to one component. Notice what the bound counts: not the $|V|-1$ edges of the final tree, but the number of synchronized scans.
Complexity Analysis
| Resource | Bound | Reason |
|---|---|---|
| Phases | $O(\log V)$ | The number of active components at least halves inside each connected region. |
| Edge work per phase | $O(E\,\alpha(V))$ | Every edge is scanned and its endpoint representatives are found with union–find. |
| Total time | $O(E\,\alpha(V)\log V)$ | Often written $O(E\log V)$ because $\alpha(V)$ grows extraordinarily slowly. |
| Auxiliary space | $O(V)$ | Parents, component sizes, and one cheapest candidate per representative; storing input/output uses $O(E)$ more. |
The phase structure exposes parallel work, but a real parallel implementation must still coordinate reductions for “cheapest per component” and concurrent unions. The sequential version remains useful, and Borůvka phases are often used as a preprocessing step that rapidly shrinks a graph before another MST strategy finishes it.
Implementation
These versions return the chosen forest edges, total weight, remaining component count, and phase count. They terminate safely on disconnected inputs and use a deterministic edge key for ties. Self-loops are ignored because they never cross a component cut.
How Borůvka Differs from Prim and Kruskal
| Algorithm | State it grows | Next-edge rule | Natural data structure | Useful intuition |
|---|---|---|---|---|
| Borůvka | Every tree in a forest | Cheapest outgoing edge per component | Union–find plus component minima | Parallel contraction |
| Kruskal | One global forest | Next globally lightest edge that avoids a cycle | Sorted edges plus union–find | Accept edges in price order |
| Prim | One connected tree | Cheapest edge leaving that tree | Priority queue | Expand one frontier |
All three are cut-property algorithms; they differ mainly in which cut or collection of cuts they expose at each step. Their outputs may differ when weights tie, while their total weight remains optimal.
Where the Phase Structure Helps
Parallel Graph Processing
Independent edge scans can propose component minima concurrently, followed by a coordinated union stage.
Distributed Graphs
Machines summarize local edges into a small set of candidates before components are merged across partitions.
Graph Contraction
A few phases can drastically reduce the component graph before Kruskal or another method finishes.
Network Design
The MST models minimum-cost backbones for wiring, roads, pipes, or communication links.
Minimum Spanning Forests
Disconnected inputs are handled naturally: each reachable region contracts to its own optimal tree.
Clustering Foundations
Cutting heavy MST edges yields a hierarchy of groups; Borůvka supplies the same optimal backbone.
Pitfalls and Edge Cases
| Mistake | What goes wrong | Robust treatment |
|---|---|---|
| Choosing per vertex after phase 1 | An edge may be internal to a larger component. | Choose one outgoing edge per current DSU representative. |
| Adding every nomination blindly | Duplicate choices or equal-weight ties can create a cycle. | Run every candidate through union–find before accepting it. |
| Assuming the input is connected | The loop never reaches one component. | Stop when a full phase performs zero merges and return a forest. |
| Using $-1$ as a missing weight | Negative-weight edges are misclassified. | Store an absent candidate separately from its weight. |
| Forgetting self-loops | A loop can look cheap but never connects components. | Ignore edges whose endpoints are identical. |
| Unstable tie handling | Runs return different valid trees, complicating tests. | Compare weight, canonical endpoints, then input position. |
| Calling each phase “free parallelism” | Concurrent minimum reduction and unions still need coordination. | Separate theoretical work from synchronization and communication costs. |
MST Versus MSF
A result with more than one remaining component is not a failed computation. It is a minimum spanning forest. Report the component count so callers can decide whether disconnected input is acceptable.
Exercises
Reason About the Phases
- Trace. Reproduce both phases of the six-vertex example and record which component nominated each accepted edge.
- Prove. Write the exchange argument for the edge $CD(5)$ using the cut $\{A,B,C\}\mid\{D,E,F\}$.
- Ties. Give all three edges of a triangle weight 1 and let its vertices break ties inconsistently. Show how three nominations can form a cycle and why union–find still returns an MST.
- Disconnect. Remove every edge crossing between $\{A,B,C\}$ and $\{D,E,F\}$. Predict the returned weight, edge count, and component count.
- Audit. Assert in code that the output has $V-c$ edges, where $c$ is the returned number of components.
- Extend. Record the selected edges and component count after every phase, then render the contraction history.
Invariant to use: a forest on $V$ vertices with $c$ connected components has exactly $V-c$ edges.