Algorithms · Minimum Spanning Trees: Kruskal, Prim and Union-Find
Spanning Trees, MSTs and the Cut and Cycle Properties
Let be a connected, undirected graph with vertices and edges. Each edge carries a weight (can be negative; can be equal to another edge's weight).
Spanning tree. A spanning tree of is a subgraph that
- is connected,
- is acyclic (a tree), and
- contains all vertices of .
Equivalently, is a set of exactly edges of that connects all vertices.
Minimum spanning tree (MST). A spanning tree whose total weight is minimum over all spanning trees of .
Facts you must be able to quote:
| Fact | Statement | Why |
|---|---|---|
| Edge count | Every spanning tree has exactly edges | A tree on vertices has edges |
| Existence | A spanning tree exists iff is connected | Standard |
| Uniqueness | If all edge weights are distinct, the MST is unique (the converse is false: ties may or may not give several MSTs) | Distinct weights make every cut/cycle comparison strict; tied edges can be swapped but need not be on a common cut or cycle |
| Number of spanning trees | Cayley: for | Not needed for MST weight, only for counting questions |
| MST of a tree | The tree itself | Only one spanning tree exists |
Convention note (important for GATE). Two indexing conventions appear in textbooks:
- 1-based style (CLRS, most GATE questions): vertices numbered ; adjacency matrix ; if no edge.
- 0-based style (most program code): vertices ; matrix .
GATE questions almost always use 1-based vertex labels () and distinct integer weights. When weights tie, the question either asks "which of the following is an MST" (any valid answer) or specifies a tie-breaking rule. Always state your tie-break.
2. The Two Structural Properties
These two lemmas are the entire theoretical foundation of every MST algorithm. Learn the proofs — they are two lines each and are asked as "prove or state".
2.1 Cut Property
Definition. A cut is a partition of into two non-empty sets. An edge crosses the cut if one endpoint is in and the other in .
Cut Property. For any cut , the minimum-weight edge crossing the cut belongs to some MST. If that edge is unique (strictly lightest), it belongs to every MST.
Proof (two lines). Let be a lightest edge crossing the cut, and let be any MST. If we are done. Otherwise contains a unique cycle; that cycle must cross the cut an even number of times, so it contains some other crossing edge . Then is a spanning tree with , so is also an MST and contains .
2.2 Cycle Property
Cycle Property. For any cycle in , if is a strictly heaviest edge on , then belongs to no MST.
Proof (two lines). Suppose an MST contains . Removing from splits into two components; the cycle must contain some other edge with endpoints in different components (since crosses the cut made by removing ). Then is a spanning tree with , contradicting minimality of .
How to use them in one line each:
- Cut property → "the cheapest edge leaving any set of already-chosen vertices is safe to add" — this is exactly Prim's rule.
- Cycle property → "the heaviest edge on any cycle can be discarded" — this is exactly Kruskal's rejection rule and reverse-delete.