Borůvka's Algorithm
–
Pseudocode
1every vertex starts as its own component2while more than one component is left:3 for each component C:4 find the cheapest edge leaving C5 add all those edges to the MST (skip one if its ends are already joined)6 merge the components they connect
Round
0
Components
0
colourone componentcheapest edge leaving a componentin the MST
What is Borůvka's Algorithm?
Borůvka's algorithm (1926) is the oldest minimum spanning tree algorithm. Like Prim's and Kruskal's, it builds the cheapest set of edges that connects every vertex.
It works in rounds. In each round, every component at once picks the cheapest edge that leaves it. All those edges are added, the components they connect merge, and the next round starts with fewer, bigger components. Since each component joins at least one other, the number of components at least halves every round.
Every component grabs its cheapest outgoing edge, all at the same time.
Using the Visualizer
- • Each colour is one component. In each round, yellow edges are the cheapest edge leaving some component.
- • Green edges are in the MST. Two components can pick the same edge; it is only added once.
- • Use the same example as on the Prim and Kruskal pages and compare: the total weight is the same.
How It Works
1. Start
Every vertex is a component by itself.
2. Cheapest edge out
Each component finds its cheapest edge to a different component.
3. Add and merge
Add all chosen edges (skipping duplicates) and merge the components.
4. Repeat
Until one component remains, or no edge leaves a component (disconnected graph).
Ties: with equal weights, two components could choose edges that form a cycle. Breaking ties by a fixed rule (here: by vertex numbers) prevents that.
Implementation
Properties & Complexity
Time Complexity
- • Rounds: at most log₂ V
- • Each round: O(E) to scan the edges
- • Total: O(E log V)
Space & Properties
- • Space: O(V) for union-find and the cheapest edges
- • Result: same total weight as Prim and Kruskal
Where It Is Used
- • Parallel and distributed MST computation (components work independently)
- • Network design and clustering, like the other MST algorithms
- • Building block of faster MST algorithms (Karger–Klein–Tarjan)
Limitations
- • Needs tie-breaking when weights repeat
- • Sequentially no faster than Kruskal or Prim
- • Undirected graphs only