Skip to content
Part IA Lent Term

The Minimum Spanning Tree Problem

A minimum spanning tree (MST) of a connected, undirected, weighted graph is a tree connecting all vertices with the smallest possible total edge weight. MSTs underpin network design, clustering, and approximation algorithms.

Definitions

Given a connected undirected graph G=(V,E)G = (V, E) with weight function w:E→Rw: E \to \mathbb{R}, a spanning tree is an acyclic subset T⊆ET \subseteq E that connects all vertices (∣T∣=∣V∣−1|T| = |V| - 1). A minimum spanning tree minimises:

w(T)=∑(u,v)∈Tw(u,v)w(T) = \sum_{(u, v) \in T} w(u, v)

MSTs need not be unique when edge weights tie.

The Cut Property

For any cut (S,V∖S)(S, V \setminus S) (a partition of VV), a light edge crossing the cut is one whose weight is minimum among all crossing edges. Light edges are not necessarily unique.

Cut Property: For any cut, every light edge crossing the cut belongs to some MST.

Proof

Let e=(u,v)e = (u, v) be a light edge crossing cut (S,V∖S)(S, V \setminus S). Suppose ee is not in some MST TT. Since TT is spanning and connected, adding ee to TT creates a unique cycle. This cycle must cross the cut at least twice: once with ee, and at least once with another edge ff crossing the cut. Since ee is a light edge, w(e)≤w(f)w(e) \le w(f). Remove ff from T∪{e}T \cup \{e\}; the resulting tree T′=T∪{e}∖{f}T' = T \cup \{e\} \setminus \{f\} has weight w(T′)=w(T)−w(f)+w(e)≤w(T)w(T') = w(T) - w(f) + w(e) \le w(T). Since TT was minimum, T′T' is also minimum, and it contains ee. So ee belongs to some MST.

The Cycle Property

Cycle Property: For any cycle in GG, the maximum-weight edge in the cycle cannot belong to any MST.

Proof

Let ee be the unique maximum-weight edge on some cycle CC. Suppose ee is in some MST TT. Removing ee partitions TT into two components. Since CC connects these components via some other edge f≠ef \neq e, adding ff and removing ee yields a spanning tree T′T' with w(T′)=w(T)−w(e)+w(f)<w(T)w(T') = w(T) - w(e) + w(f) < w(T), contradiction.

Generic MST Algorithm

Both Kruskal’s and Prim’s algorithms are instances of a generic strategy:

GENERIC-MST(G, w):
    A = empty set
    while A does not form a spanning tree:
        find a safe edge (u, v) for A
        A = A union {(u, v)}
    return A

An edge is safe for AA if A∪{e}A \cup \{e\} is a subset of some MST. The cut property provides a way to find safe edges: any light edge crossing a cut that respects AA (no edges of AA cross the cut) is safe for AA.

Proof of Safe-Edge Theorem

Let AA be a subset of some MST TT, and let (S,V∖S)(S, V \setminus S) be any cut respecting AA. Let e=(u,v)e = (u, v) be a light edge crossing the cut. If e∈Te \in T, done. Otherwise, T∪{e}T \cup \{e\} contains a cycle. This cycle must cross the cut (since ee does), so there is another edge ff on the cycle crossing the cut. f∉Af \notin A (since the cut respects AA). Remove ff; the new tree T′=T∪{e}∖{f}T' = T \cup \{e\} \setminus \{f\} is an MST with A∪{e}⊆T′A \cup \{e\} \subseteq T', so ee is safe.

Example

Graph with 6 vertices and edges: (1,2,3)(1,2,3), (1,3,1)(1,3,1), (2,3,2)(2,3,2), (2,4,4)(2,4,4), (3,4,5)(3,4,5), (3,5,2)(3,5,2), (4,5,1)(4,5,1), (4,6,3)(4,6,3), (5,6,2)(5,6,2). Weights in third position.

MST example graph

The MST has total weight 1+2+1+2+2=81 + 2 + 1 + 2 + 2 = 8 using edges: (1,3)(1,3), (2,3)(2,3), (4,5)(4,5), (5,6)(5,6), (3,5)(3,5).

Summary

ConceptDefinition
Spanning treeAcyclic subgraph connecting all vertices
MSTSpanning tree with minimum total weight
Cut propertyLight edge crossing any cut is in some MST
Cycle propertyMaximum-weight edge on a cycle is in no MST
Safe edgeAdding it to AA keeps AA subset of some MST
Respecting cutNo edges of AA cross the cut

Past Tripos: y2024p2q7, y2023p1q9.