Given a connected, undirected, weighted graph , a minimum spanning tree is a spanning tree with minimum total edge weight.
Key Properties
- A spanning tree has exactly edges.
- No cycles.
- If edge weights are distinct, the MST is unique.
Main Algorithms
Kruskal
- Sort edges by nondecreasing weight.
- Add an edge if it connects two different components.
- Stop after adding edges.
- Typical implementation: Disjoint Set Union.
- Time: (sorting dominates).
Prim
- Start from any vertex.
- Repeatedly add the minimum-weight edge crossing from visited to unvisited.
- Binary heap implementation: .
- Dense graph version (array): .
Boruvka
Repeat until only one component remains:
- Treat each vertex/component as a separate component.
- For each component, choose its cheapest outgoing edge.
- Add all chosen edges to the MST (ignore duplicates/cycles via DSU).
- Merge components.
- Each phase reduces the number of components by at least a factor of .
- Number of phases: .
- Typical total time: .
TIP
Boruvka is naturally parallelizable because each component picks its cheapest outgoing edge independently.
Correctness Intuition (Cut Property)
NOTE
For any cut , the lightest edge crossing the cut is safe: it belongs to some MST.
Kruskal, Prim, and Boruvka are correct because each step picks safe edges.
Typical Use Cases
- Network design (roads, cables, pipelines)
- Clustering (single-link hierarchical clustering)
- Approximation building block (e.g., TSP heuristics)