Trees, Spanning Trees, and Minimum Spanning Trees

A tree is a connected acyclic graph; a spanning tree of a connected graph is a subgraph that is a tree touching every vertex; a minimum spanning tree (MST) is a spanning tree of minimum total edge weight. Key result: every connected graph has a spanning tree, an -vertex tree has exactly edges, and MSTs can be found greedily in near-linear time (Kruskal, Prim, Borůvka). Applies to network design, clustering, circuit layout, and approximation algorithms. Foundational results from Cayley (1889), Borůvka (1926), Kruskal & Prim (1956).

A tree is one of the most fundamental structures in graph theory: a connected graph with no cycles. Trees on vertices have a remarkable rigidity — they have exactly edges, a unique path between any two vertices, and removing any edge disconnects them while adding any edge creates exactly one cycle. A spanning tree extracts such a minimal connected skeleton from a larger graph, and when edges carry weights (costs, distances, resistances), the minimum spanning tree is the cheapest way to keep everything connected. The surprising fact is that this global optimization problem yields entirely to local greedy decisions — picking the cheapest safe edge at each step is provably optimal, a rarity that makes MSTs a textbook example of when greed works.

The Core Insight

A tree is the "just barely connected" graph: it has the minimum number of edges needed to connect all vertices, so it is simultaneously maximally acyclic and minimally connected. Adding any edge creates a cycle; removing any edge disconnects it. For minimum spanning trees, this dual rigidity powers two equivalent optimality conditions — the cut property (the lightest edge crossing any cut is safe to include) and the cycle property (the heaviest edge in any cycle can be excluded). Together they guarantee that greedy algorithms construct the optimum.

Formal Statement

Graph, Tree, Forest

Let be an undirected graph with vertex set () and edge set ().

  • A path is a sequence of distinct vertices with each .
  • A cycle is a path of length with and otherwise distinct vertices.
  • is connected if there is a path between every pair of vertices.
  • is acyclic if it contains no cycle.
  • A tree is a connected acyclic graph. A forest is an acyclic graph (a disjoint union of trees).
  • A leaf is a vertex of degree 1.

Spanning Tree and Minimum Spanning Tree

Let be a connected graph.

  • A spanning subgraph is a subgraph containing all vertices of .
  • A spanning tree of is a spanning subgraph that is a tree: with , connected and acyclic.
  • Given a weight function , the weight of a spanning tree is
1
⟳the total weight is just the sum over the chosen edges; nothing more is hidden.
  • A minimum spanning tree (MST) is a spanning tree minimizing :
2
⟳the minimization ranges over the finite (but possibly exponential) set of all spanning trees.

Equivalent Characterizations of a Tree

For a graph on vertices, the following are equivalent:

  1. is a tree (connected and acyclic).
  2. is connected and has exactly edges.
  3. is acyclic and has exactly edges.
  4. Between any two vertices there is a unique path.
  5. is connected, but removing any single edge disconnects it (minimally connected).
  6. is acyclic, but adding any single edge creates a cycle (maximally acyclic).

Edge Count of a Tree

Every tree on vertices has exactly edges:

3
⟳induct on — removing a leaf removes exactly one vertex and one edge, preserving the tree property.

Cayley's Formula

The number of distinct labeled spanning trees of the complete graph is

4
⟳bijection with Prüfer sequences — strings of length over an -symbol alphabet.

Matrix–Tree Theorem (Kirchhoff)

For a connected graph , let be the Laplacian ( = degree diagonal matrix, = adjacency matrix). The number of spanning trees equals any cofactor of :

5

where deletes row and column .

⟳Cauchy–Binet applied to the incidence matrix; each nonzero minor corresponds to a spanning tree.

Why It Holds / Derivation

Tree has exactly $n-1$ edges

We prove statement [3] by induction on .

Step 1 (Base case). For , the tree is a single vertex with edges. ✓ Step 2 (A tree has a leaf). A finite tree with vertices has at least two leaves. If every vertex had degree , we could keep walking along unused edges and, in a finite acyclic graph, eventually repeat a vertex — forming a cycle, contradicting acyclicity. Step 3 (Inductive step). Let have vertices. Take a leaf and remove it together with its single incident edge, giving on vertices. Removing a leaf cannot create a cycle and cannot disconnect (no path used except as an endpoint), so is a tree. Step 4 (Apply hypothesis). By induction has edges. Restoring and its edge gives with edges.

Cut Property — lightest crossing edge is safe

Let be any nontrivial cut (partition of vertices). Suppose edge with , is the strictly minimum-weight edge crossing the cut. We claim every MST contains .

Step 1. Suppose for contradiction an MST does not contain . Step 2. Since is a spanning tree, adding creates a unique cycle (Theorem characterization 6). The cycle starts in , ends in (it's a cycle through ), so it must cross the cut an even number of times; thus contains at least one other edge crossing the cut. Step 3. Since is the strict minimum crossing edge, . Step 4. Form . This is connected (we removed an edge from a cycle) and has edges, so it is a spanning tree with , contradicting minimality of . Hence every MST contains .

Cycle Property — heaviest cycle edge is excludable

Let be any cycle in and let be a strictly maximum-weight edge of . Then no MST contains .

Step 1. Suppose an MST contains . Step 2. Removing splits into two components, with and on opposite sides. The rest of cycle (the path ) connects to , so it must contain some edge crossing this split, . Step 3. Since is the strict maximum on , . Step 4. Then is a spanning tree with — contradiction.

Uniqueness of the MST

If all edge weights are distinct, the minimum spanning tree is unique.

⟳combine the cut and cycle properties — every edge is either forced in (lightest across some cut) or forced out (heaviest on some cycle), leaving no choices.

Otakar Borůvka | 1899–1995

The Czech mathematician Otakar Borůvka published the first MST algorithm in 1926, motivated by a concrete engineering problem: the Moravian electric power company asked how to interconnect towns with the least total length of cable. His algorithm — repeatedly contracting each component's cheapest outgoing edge in parallel — predates both Kruskal's and Prim's by three decades and is enjoying a modern revival because its parallelism suits GPU and distributed computation. Borůvka also worked in differential geometry and group theory, but this early applied paper became one of the founding documents of combinatorial optimization.

Building Intuition

Picture the vertices as islands and candidate edges as bridges with construction costs. A spanning tree is the cheapest way to make all islands reachable without wasteful redundancy — every extra bridge beyond would either be useless (creating a loop) or could replace a more expensive one.

The cut property is the "no regrets" rule: if you split the islands into two groups, the single cheapest bridge connecting the groups can never be wrong — you must cross that gap somehow, and that's the cheapest way to do it.

The cycle property is its mirror: if your bridges ever form a loop, the most expensive bridge in the loop is redundant — you can always reach across the loop another way, so drop it.

Greedy MST algorithms are just two strategies for applying these rules: Kruskal sorts all bridges cheapest-first and adds each one unless it closes a loop; Prim grows a single connected blob, always grabbing the cheapest bridge leaving the blob.

Kruskal's algorithm building an MST: edges added in increasing weight, skipping any that form a cycle

MST (gold) vs. rejected edges (gray) 2 3 1 4 7 6 9 A B C D E MST weight = 1+2+3+4 = 10

Worked Examples

Kruskal's algorithm on a 5-vertex graph

Given: Vertices with weighted edges: . Goal: Find the MST using Kruskal (sort edges, add cheapest-first, skip cycles). Step 1 — Sort by weight: . Step 2 — Process each edge (using a disjoint-set / union–find structure):
  • : components separate → add. Sets: .
  • : separate → add. Sets: .
  • : separate → add. Sets: .
  • : separate → add. Sets: — all connected.
  • : and already same set → skip (cycle).
  • We now have edges; stop.
Step 3 — Total weight: .

Prim's algorithm from a start vertex

Given: Same graph as above. Run Prim starting from vertex (grow one connected blob, always take the cheapest edge leaving it). Step 1 — Start: Tree . Frontier edges: . Step 2: Cheapest is → add . Tree . Frontier: . Step 3: Cheapest is → add . Tree . Frontier: (drop , both endpoints now inside). Step 4: Cheapest is → add . Tree . Frontier: . Step 5: Cheapest is → add . All vertices included. Step 6 — Total weight: .

Note both algorithms produce the same tree here — guaranteed because all weights are distinct (Uniqueness Theorem).

Common Misconceptions

"The MST gives the shortest path between two vertices." It does not. The MST minimizes total edge weight across the whole graph, not the distance between any particular pair. The path between two vertices in the MST can be much longer than their shortest path in the original graph. Shortest-path trees (from Dijkstra) and minimum spanning trees are different objects with different optimality criteria. "More edges means better connectivity, so add a few extra." A spanning tree has exactly edges. Any additional edge creates a cycle and increases cost without improving connectivity — the tree is already connected. "With repeated weights the MST is still unique." Only distinct weights guarantee uniqueness. With ties there can be several MSTs of equal minimum weight.

MST ≠ shortest-path tree

Take a triangle with weights , , .

  • MST: edges and , total weight . The MST path from to goes with length .
  • Shortest path to in the original graph: the direct edge .

So the unique path within the MST () is longer than the true shortest path (). The MST is globally cheapest to build but does not preserve pairwise shortest distances.

Connections

Trees and MSTs sit at the crossroads of several areas:

  • Graph Connectivity — a spanning tree is the minimal certificate that a graph is connected; the number of edges to delete to disconnect relates to cuts used in the cut property.
  • Greedy Algorithms — MSTs are the canonical case where greedy is optimal, formalized by the theory of Matroids: the forests of a graph form a graphic matroid, and the greedy algorithm is optimal precisely because the independent sets form a matroid.
  • Shortest Path Problem — Prim's algorithm is structurally almost identical to Dijkstra's, differing only in the key used (edge weight vs. accumulated distance).
  • Linear Algebra — the Matrix–Tree Theorem [5] counts spanning trees via the Laplacian determinant, linking combinatorics to spectral graph theory.
  • Network Flows and Minimum Cut — the cut property is a combinatorial cousin of max-flow/min-cut duality.

Real-World Applications

  1. Telecommunication & power grid design — Borůvka's original 1926 problem: lay minimum total cable to connect all towns/substations. Still used in fiber-optic and electrical network planning.
  2. Cluster analysis (single-linkage clustering) — building an MST then removing the heaviest edges partitions data into clusters; the basis of the classic single-linkage hierarchical method and of the DBSCAN/HDBSCAN family.
  3. Approximation for the Traveling Salesman Problem — doubling an MST and shortcutting gives a 2-approximation; Christofides' algorithm improves this to 1.5 using an MST plus a matching.
  4. Image segmentation & computer vision — Felzenszwalb–Huttenlocher segmentation grows regions via MST-like merging of pixel-affinity graphs.
  5. Circuit and VLSI layout — routing wires (Steiner/rectilinear MSTs) to minimize total interconnect length and capacitance.
  6. Phylogenetics & taxonomy — minimum spanning networks approximate evolutionary trees connecting genetic sequences with minimal total mutation distance.
  7. Network protocols — the Spanning Tree Protocol (STP, IEEE 802.1D) keeps Ethernet bridged networks loop-free by computing a spanning tree of switches.

Historical Development

  • 1847 — Gustav Kirchhoff introduces spanning trees while analyzing electrical circuits, proving the Matrix–Tree Theorem [5] for counting them.
  • 1857 — Arthur Cayley uses "tree" terminology in studies of chemical isomers and combinatorial enumeration.
  • 1889 — Cayley publishes the formula [4] for the number of labeled trees.
  • 1918 — Heinz Prüfer gives an elegant bijective proof of Cayley's formula via Prüfer sequences.
  • 1926 — Otakar Borůvka publishes the first MST algorithm, solving the Moravian power-network problem.
  • 1930 — Vojtěch Jarník independently devises the algorithm later rediscovered as Prim's.
  • 1956 — Joseph Kruskal publishes his cheapest-edge-first greedy algorithm in a now-famous short paper.
  • 1957 — Robert Prim publishes the grow-one-tree algorithm (independently of Jarník), naming it after himself.
  • 1975–1995 — Andrew Yao, Michael Fredman, Robert Tarjan and others push MST complexity toward linear time; in 1995 Karger, Klein, and Tarjan give an expected-linear-time randomized algorithm, and the exact deterministic optimal-comparison complexity remains studied today.

Subtleties & Limits

The exact deterministic complexity of computing an MST in the comparison model is not fully resolved. We have:

  • A randomized algorithm (Karger–Klein–Tarjan, 1995) running in expected time.
  • A deterministic algorithm (Chazelle, 2000) running in time, where is the inverse-Ackermann function — almost but not provably linear.
  • Bernard Chazelle and Seth Pettie's optimal deterministic algorithm runs in provably optimal time, but its exact asymptotic complexity is unknown — it equals the (unknown) decision-tree complexity of the MST problem.

So a genuinely open question persists: Is there a deterministic linear-time, comparison-based MST algorithm? Related open directions include MST maintenance under dynamic edge insertions/deletions and parallel/distributed MST lower bounds in the CONGEST model.

See Also

Graph Connectivity · Greedy Algorithms · Matroids · Shortest Path Problem · Steiner Tree Problem · Spectral Graph Theory · Disjoint Set Union · Cayley's Formula · Matrix–Tree Theorem

Before this

Where this leads