Minimum spanning tree algorithms
Introduction / Definition
A minimum spanning tree (MST) is a spanning tree with minimum total edge weight. Kruskal's algorithm repeatedly chooses the cheapest edge that does not create a cycle. Prim's algorithm grows one connected tree by adding the cheapest edge leaving the current tree. Both are standard greedy algorithms.
Syntax / Mathematical Form
MST = argmin over spanning trees T of Σ_{e∈T} w(e)
Detailed Explanation
Kruskal sorts edges by weight and uses a disjoint-set structure to detect cycles. Prim maintains a growing vertex set and repeatedly selects a minimum crossing edge. For connected weighted undirected graphs, both produce an MST.
Example / Worked Example
Edges AB=1, BC=2, AC=5. Choose AB and BC; total=3.
Output / Result
MST weight = 3.
Important Points / Notes
- MST minimizes total edge weight.
- Kruskal is edge-oriented.
- Prim is growth-oriented.
- Negative weights are allowed for MST algorithms.
Mini Practice Question
Find the MST of edges AB=1, AC=4, BC=2.