Cayley's Formula ($n^{n-2}$ trees)
Statement
The number of distinct labeled trees on the vertex set is:
For : — interpreted as (one trivial tree).
For : (single edge ).
For : .
For : .
Visualization
All 3 labeled trees on :
Tree 1: 1 ─ 2 ─ 3 (1 is leaf, 3 is leaf, 2 is center)
Tree 2: 1 ─ 3 ─ 2 (1 is leaf, 2 is leaf, 3 is center)
Tree 3: 2 ─ 1 ─ 3 (2 is leaf, 3 is leaf, 1 is center)
| Tree | Edges | Center |
|---|---|---|
| 2 | ||
| 3 | ||
| 1 |
Three trees, matching .
Prüfer sequence bijection for : sequences of length 1 from — there are 3 such sequences, one per tree. The Prüfer sequence encodes a tree by repeatedly deleting the leaf with smallest label and recording its neighbor.
For : Prüfer sequences have length 2 over , giving sequences, hence 16 trees.
| Prüfer sequences | ||
|---|---|---|
| 2 | 1 | 1 empty sequence |
| 3 | 3 | 3 sequences of length 1 |
| 4 | 16 | 16 sequences of length 2 |
| 5 | 125 | 125 sequences of length 3 |
Proof Sketch
- Prüfer sequences: Given a labeled tree on , form a sequence by: at each step, remove the leaf with smallest label and record its (unique) neighbor. The result is a sequence of entries from .
- Bijection: The map is a bijection between labeled trees on vertices and sequences of length from .
- Counting: There are such sequences, so .
- Reconstruction: Given a Prüfer sequence , reconstruct the tree: at step , find the smallest element not in the remaining sequence and add an edge to . The last two elements form the final edge.
Connections
Cayley's formula counts spanning trees of the complete graph , directly connecting to the Handshake LemmaHandshake LemmaThe sum of all vertex degrees in a finite graph equals twice the number of edges.Read more → (all vertices have degree in any spanning tree). The count also equals the number of parking functions of length , linking to Catalan NumbersCatalan NumbersThe ubiquitous sequence counting balanced parentheses, binary trees, and Dyck pathsRead more → combinatorics. The Matrix-Tree TheoremMatrix-Tree TheoremThe number of spanning trees of a graph equals any cofactor of its Laplacian matrix.Read more → gives an alternative proof via the determinant of the Laplacian of : .
Lean4 Proof
-- Verify Cayley's formula for small n by direct computation.
-- n = 3: T_3 = 3^1 = 3
example : (3 : ℕ) ^ (3 - 2) = 3 := by norm_num
-- n = 4: T_4 = 4^2 = 16
example : (4 : ℕ) ^ (4 - 2) = 16 := by norm_num
-- n = 5: T_5 = 5^3 = 125
example : (5 : ℕ) ^ (5 - 2) = 125 := by norm_numReferenced by
- Matrix-Tree TheoremGraph Theory
- Matrix-Tree TheoremGraph Theory
- Dilworth's TheoremGraph Theory
- Euler's Formula for Planar GraphsGraph Theory