Skip to content
Part IA Lent Term

The Safe-Edge Theorem

The safe-edge theorem is the correctness foundation for all greedy MST algorithms. It formalises the cut property into a constructive rule: given a partial MST, any light edge crossing a cut that respects the current edge set can be safely added.

Formal Statement

Let G=(V,E)G = (V, E) be a connected undirected graph with weight function ww.

Let AEA \subseteq E be a subset of some MST.

Let (S,VS)(S, V \setminus S) be any cut of GG that respects AA (no edge in AA crosses the cut).

Let (u,v)(u, v) be a light edge crossing (S,VS)(S, V \setminus S) (minimum weight among all crossing edges).

Then (u,v)(u, v) is a safe edge for AA: A{(u,v)}TA \cup \{(u, v)\} \subseteq T' for some MST TT'.

Proof (Full)

Let TT be an MST containing AA. If (u,v)T(u, v) \in T, we are done (T=TT' = T).

Otherwise, (u,v)T(u, v) \notin T. Since TT is a spanning tree, there is a unique path pp from uu to vv in TT. Because (u,v)(u, v) crosses the cut, and TT connects all vertices, the path pp must cross the cut at least once. Let (x,y)(x, y) be an edge on pp that crosses the cut.

Now (x,y)A(x, y) \notin A, because the cut respects AA (no edge of AA crosses it).

Consider T=T{(x,y)}{(u,v)}T' = T \setminus \{(x, y)\} \cup \{(u, v)\}:

  • TT' is connected (removing (x,y)(x, y) splits TT into two components; adding (u,v)(u, v) reconnects them, since uu and vv are in opposite components)
  • TT' is acyclic (adding (u,v)(u, v) to TT created one cycle; removing (x,y)(x, y) breaks it)
  • TT' has V1|V|-1 edges, so it is a spanning tree

Weight comparison:

w(T)=w(T)w(x,y)+w(u,v)w(T)w(T') = w(T) - w(x, y) + w(u, v) \le w(T)

The inequality follows because (u,v)(u, v) is a light edge crossing the cut, so w(u,v)w(x,y)w(u, v) \le w(x, y).

Since TT is minimum, w(T)w(T)w(T') \ge w(T). Combined, w(T)=w(T)w(T') = w(T), so TT' is also an MST.

ATA \subseteq T and (x,y)A(x, y) \notin A, so AT{(x,y)}TA \subseteq T \setminus \{(x, y)\} \subset T'. Also (u,v)T(u, v) \in T'. Hence A{(u,v)}TA \cup \{(u, v)\} \subseteq T', proving (u,v)(u, v) is safe. \square

Corollary

Let GA=(V,A)G_A = (V, A) be the forest formed by the current edges (initially A=A = \emptyset, so GAG_A has V|V| isolated vertices). If (u,v)(u, v) is a light edge connecting two distinct components of GAG_A, then (u,v)(u, v) is safe.

Proof: For any component CC of GAG_A, the cut (C,VC)(C, V \setminus C) respects AA (since AA only contains edges within components, never between them). A light edge connecting CC to another component crosses this cut, so by the safe-edge theorem, it is safe.

How Kruskal and Prim Use It

  • Kruskal: processes edges in increasing weight order. When considering edge (u,v)(u, v) connecting two different trees in the forest GAG_A, it crosses the cut (Cu,VCu)(C_u, V \setminus C_u) where CuC_u is the component containing uu. Since edges are processed in weight order and no lighter edge could still connect these components, (u,v)(u, v) is a light edge for that cut, hence safe.

  • Prim: grows a single tree from a root. At each step, the edge of minimum weight connecting a vertex in the tree to a vertex outside is a light edge crossing the cut (tree, rest-of-graph). Hence safe.

Summary

TermDefinition
Respects AANo edge in AA crosses the cut
Light edgeMinimum weight among edges crossing a given cut
Safe edgeAdding it preserves the invariant “subset of some MST”
Proof techniqueSwap argument: replace a crossing edge in TT with the light edge

Past Tripos: y2024p2q7, y2023p1q9.