MathLabs
TheoremProved

Cayley's formula

Statement

The number of distinct labeled trees on the vertex set {1,…,n}\{1,\dots,n\} (for n≥2n\ge2) is nn−2n^{n-2}.

Why is it true?

It answers a purely combinatorial question — how many different ways can nn distinguishable points be wired into a tree-shaped network — with a strikingly simple closed formula, and the encoding trick used to prove it (Prüfer sequences) turns "count the trees" into "count the sequences," a much easier problem.

Proof sketch

Fix the vertex set {1,…,n}\{1,\dots,n\} and, for n≥2n\ge2, define the Prüfer sequence of a labeled tree TT: repeatedly find the leaf with the smallest label, write down the label of its unique neighbor, and delete that leaf; stop once 22 vertices remain. This records n−2n-2 labels (one per deletion, since we start with nn vertices and stop at 22), so every labeled tree produces a sequence in {1,…,n}n−2\{1,\dots,n\}^{n-2}.

There are exactly nn−2n^{n-2} such sequences, since each of the n−2n-2 positions is independently any of the nn labels. It remains to show this encoding is a bijection, so that labeled trees are in exact one-to-one correspondence with these sequences.

The key fact is that in the Prüfer sequence, label ii appears exactly deg⁡(i)−1\deg(i)-1 times: every time one of ii's neighbors is deleted as a leaf, ii is written down once, and ii itself is only ever deleted (contributing no writes) once all but one of its incident edges are gone. In particular, the labels that never appear in the sequence are exactly the original leaves. This lets us decode: given a sequence (a1,…,an−2)(a_1,\dots,a_{n-2}), repeatedly take the smallest label not currently used as a remaining sequence entry or already attached, join it by an edge to the first remaining sequence entry, remove that label from further consideration and remove that entry from the sequence; after all n−2n-2 entries are consumed, join the 22 labels left over by a final edge.

This decoding procedure exactly reverses the encoding step by step — at each stage it identifies the same smallest-label leaf and the same neighbor that the encoder would have recorded, by induction on the number of vertices remaining. So encoding and decoding are mutually inverse, giving a bijection between labeled trees on nn vertices and sequences in {1,…,n}n−2\{1,\dots,n\}^{n-2}. Since there are nn−2n^{n-2} such sequences, there are exactly nn−2n^{n-2} labeled trees on nn vertices.

Topics that use this theorem

Step-by-step proofs

No step-by-step proof yet for this theorem.

References

  1. Reinhard Diestel (2017). Graph Theory
  2. David R. Karger, Philip N. Klein, Robert E. Tarjan (1995). A randomized linear-time algorithm to find minimum spanning trees · DOI:10.1145/201019.201022
  3. Aaron Schild (2017). An almost-linear time algorithm for uniform random spanning tree generation · arXiv:1711.06455 [preprint, not peer-reviewed]