Minimum spanning trees & the cut property
◈ 3 cardsWhy an MST has exactly |V|−1 edges, and the one theorem (the cut property / safe edge) that justifies both Kruskal and Prim.
The minimum-spanning-tree problem
Given a connected, undirected graph with a real weight on each edge, a spanning tree is an acyclic subset that connects all the vertices. A minimum spanning tree (MST) is a spanning tree of minimum total weight . This models any "connect everything as cheaply as possible" problem: lay cable to every building, wire a circuit, build roads between cities.
The solution is always a tree for two reasons. It must span — touch all vertices — and it must be acyclic: a cycle would contain a removable edge whose deletion keeps the graph connected but lowers the weight, so no minimum solution has one. A connected acyclic graph on vertices has exactly edges, so every MST has exactly edges.
MSTs are not necessarily unique — if two edges tie in weight, swapping one for the other can give a second MST with the same total.
Growing an MST one safe edge at a time
Both classic algorithms follow a generic greedy template. Start with and keep the loop invariant: is a subset of some MST. At each step add a safe edge — an edge such that is still a subset of some MST. After safe additions, is an MST. The whole game is: how do you know an edge is safe?
The cut property (Theorem 21.1) — the one MST theorem
First, the vocabulary:
- A cut is a partition of the vertices into two sides.
- An edge crosses the cut if its endpoints are on different sides.
- The cut respects if no edge of crosses it.
- A light edge crossing a cut is a minimum-weight edge among all edges crossing it.
Theorem (cut property). Let be a subset of some MST, let be any cut that respects , and let be a light edge crossing that cut. Then is safe for .
Worked proof (the exchange / cut-and-paste argument). Let be an MST containing . If we are done. Otherwise, adding to creates a cycle; that cycle crosses the cut an even number of times, so it contains some other crossing edge . Because the cut respects , . Form Since is light, , so — thus is also an MST. And (we only removed a non- edge) with , so . Therefore is safe.
This is the same exchange argument as activity selection and Huffman codes from the greedy module: take any optimal solution, swap in the greedy choice, show the result is no worse. Corollary 21.2 specializes it to the natural cut induced by a connected component of the forest — and that corollary is exactly what makes Kruskal and Prim correct. Kruskal keeps many components and merges them; Prim grows one component; both always add the lightest cross-component edge.