Sub topic 4
The Cut Property: Why the Lightest Crossing Edge Is Safe
This chapter assumes you know what a spanning tree and a minimum spanning tree (MST) are, from the previous chapters. You should also be comfortable with cycles in undirected graphs and with basic Python. The cut property is the fact that makes greedy MST algorithms correct. Both Kruskal's and Prim's algorithms come down to applying it again and again.
Cuts and Crossing Edges
A cut splits the vertex set V into two non-empty groups, S and V − S. An edge crosses the cut when one endpoint is in S and the other is in V − S.
Here is the running example graph, with the cut S = {0, 1}:
Edges 0–2 (weight 4), 1–2 (weight 3), and 1–3 (weight 2) cross the cut. The lightest of them is 1–3.
The Statement
Cut property. Let A be a set of edges contained in some MST. Take any cut that respects A, meaning no edge of A crosses it. If e is a lightest edge crossing that cut, then A ∪ {e} is also contained in some MST.
An edge that can be added this way is called safe. With A empty, the property says something simpler: for any cut, the lightest crossing edge belongs to some MST.
Why It Holds: The Exchange Argument
Let T be an MST that contains A. If T already contains e, there is nothing to prove. Otherwise:
- Adding e = (u, v) to T creates exactly one cycle.
- The edge e takes that cycle from S to V − S. The cycle must cross back to close, so some other edge f on it also crosses the cut.
- The cut respects A, so f is not in A.
- The edge e is a lightest crossing edge, so w(e) ≤ w(f).
- T' = T − {f} + {e} is still a spanning tree, because removing f breaks the only cycle. Its weight is w(T) − w(f) + w(e) ≤ w(T).
So T' is an MST that contains A ∪ {e}.
Checking It in Code
The function below finds a lightest crossing edge for a given cut. It uses the same (weight, u, v) edge format as the rest of the tutorial.
def lightest_crossing_edge(edges, S):
# edges: list of (weight, u, v); S: set of vertices on one side of the cut
crossing = [(w, u, v) for w, u, v in edges if (u in S) != (v in S)]
return min(crossing) if crossing else None
edges = [(1, 0, 1), (4, 0, 2), (3, 1, 2), (2, 1, 3), (5, 2, 3)]
print(lightest_crossing_edge(edges, {0})) # (1, 0, 1)
print(lightest_crossing_edge(edges, {0, 1})) # (2, 1, 3)
print(lightest_crossing_edge(edges, {0, 1, 3})) # (3, 1, 2)Those three edges have total weight 6 and form the MST of this graph. Each choice also respects the cut condition. The edges chosen so far always lie inside S, so none of them crosses the next cut.
Common Errors
| Mistake | Correction |
|---|---|
| Choosing the lightest edge in the whole graph for every step | Only the lightest edge crossing the current cut is guaranteed safe. |
| Using a cut that an already chosen edge crosses | The cut must respect A, or the exchange in step 3 can remove an edge you meant to keep. |
| Claiming the edge is in *every* MST | When weights tie, the edge is only guaranteed to be in *some* MST. |
| Forgetting that S must be non-empty and proper | A cut needs vertices on both sides, or no edge crosses it. |
Exercise
In the example graph, take the cut S = {2} and A = {} (no edges chosen yet). Which edge does the cut property certify as safe, and why is edge 2-3 never a candidate for any cut here?
Show answer
The edges crossing the cut are 0-2 (4), 1-2 (3), and 2-3 (5). The lightest is 1-2 with weight 3, so 1-2 is safe. Edge 2-3 is the heaviest edge on the cycles 1-2-3 and 0-2-3-1. Any cut that 2-3 crosses is also crossed by another edge of the same cycle, and that edge is lighter. So 2-3 is never the lightest crossing edge for any cut. That observation leads to the cycle property in the next chapter.