Sub topic 4
The Cut Property: Why the Lightest Crossing Edge Is Safe
This chapter assumes you already know three things from earlier chapters. A spanning tree of a connected graph with V vertices uses exactly V − 1 edges and has no cycles. A minimum spanning tree (MST) is a spanning tree with the smallest possible total weight. Adding one edge to a tree creates exactly one cycle. You should also be able to read basic Python.
Both Prim's and Kruskal's algorithms are greedy. They add one edge at a time and never undo a choice. A greedy algorithm is only correct if each choice can be justified, and the cut property gives that justification. Later chapters build both algorithms on top of it, so the definitions and the proof here are worth learning carefully.
Cuts and Crossing Edges
A cut of a graph G = (V, E) splits the vertices into two non-empty groups, S and V − S. Every vertex belongs to exactly one side.
An edge crosses the cut when one endpoint is in S and the other is in V − S. Edges with both endpoints on the same side do not cross.
A light edge for a cut is a crossing edge whose weight is the minimum among all crossing edges. If several crossing edges share that minimum weight, each of them is a light edge.
Here is the four-vertex graph used throughout this tutorial. It has edges 0–1 (weight 1), 0–2 (4), 1–2 (3), 1–3 (2) and 2–3 (5). The diagram shows it cut with S = {0, 1}.
For this cut, the crossing edges are 0–2, 1–2 and 1–3. The light edge is 1–3 with weight 2. The edges 0–1 and 2–3 do not cross, so they play no part in this cut.
Statement of the Cut Property
The cut property comes in two strengths. The difference between them is how they handle ties.
Strict version. For any cut, if edge e is the unique lightest crossing edge, then e belongs to every MST of the graph.
General version. For any cut, every light edge belongs to some MST.
Greedy algorithms rely on a third form, which applies to a partly built answer. A set of edges A respects a cut when no edge of A crosses it.
Safe-edge version. Suppose A is a subset of some MST, and the cut (S, V − S) respects A. Then any light edge e of that cut is safe for A. Safe means A ∪ {e} is still a subset of some MST.
The safe-edge version supports an inductive argument. Start with A empty, which is trivially inside some MST. Each time you add a safe edge, you stay inside some MST. After V − 1 additions, A is an MST.
The Exchange Argument
All three versions share one proof technique, called an exchange argument. You take an optimal solution that lacks the edge you want, swap that edge in, and show the result is no worse.
Here is the proof in full.
- Let T be any MST, and let e = (u, v) be a light edge with u in S and v in V − S. If e is in T, there is nothing to prove.
- Otherwise, T contains exactly one path P from u to v. P starts in S and ends in V − S, so at least one edge f on P crosses the cut.
- Remove f from T. The tree splits into two components, with u in one and v in the other, because f was on the only path between them.
- Add e. It reconnects the two components, so T′ = T − f + e is again a spanning tree with V − 1 edges.
- Both e and f cross the cut, and e is a lightest crossing edge, so w(e) ≤ w(f). Therefore w(T′) = w(T) − w(f) + w(e) ≤ w(T).
- T is minimum, so w(T′) cannot be smaller. T′ is therefore also an MST, and it contains e. This proves the general version.
For the strict version, if e is the unique lightest crossing edge then w(e) < w(f). That makes w(T′) < w(T), which contradicts T being minimum. So the case "e is not in T" can never happen, and e is in every MST.
For the safe-edge version, pick T to be an MST that contains A. The cut respects A, so the crossing edge f is not in A. Removing f leaves A intact, so A ∪ {e} ⊆ T′.
Applying the Property by Hand
Apply the property to the example graph, each time choosing a cut that respects the edges picked so far.
| Step | Cut side S | Crossing edges (weight) | Light edge | Edges chosen so far |
|---|---|---|---|---|
| 1 | {0} | 0–1 (1), 0–2 (4) | 0–1 | 0–1 |
| 2 | {0, 1} | 0–2 (4), 1–2 (3), 1–3 (2) | 1–3 | 0–1, 1–3 |
| 3 | {0, 1, 3} | 0–2 (4), 1–2 (3), 2–3 (5) | 1–2 | 0–1, 1–3, 1–2 |
After three steps there are V − 1 = 3 edges with total weight 1 + 2 + 3 = 6. That is the MST. Each step grew S by one vertex. This is exactly the pattern Prim's algorithm follows in a later chapter. Kruskal's algorithm uses different cuts, but the same property justifies each of its choices.
Checking the Property by Brute Force
On a small graph you can test the strict version directly. The program below lists every spanning tree, keeps the minimum ones, and then checks every cut. Each cut is counted once by requiring vertex 0 to be in S.
from itertools import combinations
edges = [(1, 0, 1), (4, 0, 2), (3, 1, 2), (2, 1, 3), (5, 2, 3)] # (weight, u, v)
n = 4
def is_spanning_tree(n, tree):
# n - 1 edges with no cycle always form a spanning tree.
parent = list(range(n))
def find(x):
while parent[x] != x:
x = parent[x]
return x
for _, u, v in tree:
ru, rv = find(u), find(v)
if ru == rv:
return False
parent[ru] = rv
return True
def all_msts(n, edges):
trees = [t for t in combinations(edges, n - 1) if is_spanning_tree(n, t)]
best = min(sum(w for w, _, _ in t) for t in trees)
return [set(t) for t in trees if sum(w for w, _, _ in t) == best]
def crossing_edges(S, edges):
return [e for e in edges if (e[1] in S) != (e[2] in S)]
msts = all_msts(n, edges)
print("number of MSTs:", len(msts))
for size in range(1, n):
for combo in combinations(range(n), size):
S = set(combo)
if 0 not in S:
continue # (S, V-S) and (V-S, S) are the same cut
light = min(crossing_edges(S, edges))
in_all = all(light in t for t in msts)
print(sorted(S), "light edge:", light, "in every MST:", in_all)Output:
number of MSTs: 1
[0] light edge: (1, 0, 1) in every MST: True
[0, 1] light edge: (2, 1, 3) in every MST: True
[0, 2] light edge: (1, 0, 1) in every MST: True
[0, 3] light edge: (1, 0, 1) in every MST: True
[0, 1, 2] light edge: (2, 1, 3) in every MST: True
[0, 1, 3] light edge: (3, 1, 2) in every MST: True
[0, 2, 3] light edge: (1, 0, 1) in every MST: TrueAll weights in this graph are distinct, so every light edge is unique and lies in the single MST. Different cuts can share the same light edge. Edge 0–1 is the light edge of four of the seven cuts.
Common Errors
- Ignoring ties. If two crossing edges share the minimum weight, neither is guaranteed to be in every MST. You can only say each is in some MST. The exercises below show a concrete case.
- Using a cut that crosses a chosen edge. The safe-edge version requires the cut to respect A. If you pick a cut that A crosses, the light edge of that cut can still be in an MST, but the proof no longer promises it is compatible with A.
- Confusing the light edge of a cut with the lightest edge overall. The globally lightest edge is light for every cut it crosses, so it is always safe. The light edge of a particular cut can be fairly heavy. Edge 1–2, with weight 3, is in the MST because it is light for the cut {0, 1, 3}.
- Reading the property backwards. The cut property says which edges to include. It does not say a heavier crossing edge is excluded. Edge 0–2 crosses the cut {0} and is not light there, yet that alone does not rule it out. Excluding edges is the job of the cycle property in the next chapter.
- Applying it to directed graphs. The exchange argument assumes undirected paths. The directed version of the problem, minimum spanning arborescence, needs a different algorithm (Chu–Liu/Edmonds).
- Worrying about negative weights. The proof only compares w(e) with w(f), so negative and zero weights cause no trouble.
Exercise
In the example graph, take the cut S = {0, 2}. List the crossing edges, name the light edge, and say whether the strict version of the cut property applies.
Show answer
The crossing edges are 0–1 (1), 1–2 (3) and 2–3 (5). Edge 0–2 does not cross because both of its endpoints are in S. The light edge is 0–1 with weight 1. It is the unique minimum, so the strict version applies and 0–1 is in every MST.
Exercise
A triangle has vertices 0, 1, 2 and edges 0–1, 1–2, 0–2, all with weight 1. For the cut S = {0}, is the light edge 0–1 in every MST? What does the cut property guarantee here?
Show answer
No. The crossing edges 0–1 and 0–2 tie at weight 1, and the MST {1–2, 0–2} with weight 2 does not contain 0–1. The general version only guarantees that 0–1 is in some MST, for example {0–1, 1–2}. The same holds for 0–2.
Exercise
Suppose A = {0–1} in the example graph. Does the cut S = {0} respect A? Explain why the safe-edge version needs a different cut to choose the next edge.
Show answer
No. Edge 0–1 crosses the cut {0}, so the cut does not respect A. Its light edge is 0–1 itself, which is already chosen, so the cut gives nothing new. A cut that respects A, such as S = {0, 1}, keeps 0 and 1 on the same side. Its light edge, 1–3, is guaranteed safe to add.
Exercise
In the exchange argument, why must the path P from u to v in T contain at least one edge that crosses the cut?
Show answer
P starts at u, which is in S, and ends at v, which is in V − S. A walk that begins on one side and ends on the other must step from S into V − S at least once, and the edge used for that step crosses the cut.