Math 2.0

Combinatorics Proof

Proof of Cayley's formula by Prüfer sequences

Builds on TreePrüfer sequenceEvery finite tree with at least two vertices has a leafConnected graphAcyclic graphCycleEvery walk contains a pathPathDegree of a vertexNumber of functions between finite setsBijection principle

Proof

We show that the Prüfer sequence is a bijection, by induction on the number of vertices. For the induction we allow any finite set of integers as vertex set.

  1. For a finite set S⊆ℤS \subseteq \Z with ∣S∣=n≥2\abs{S} = n \ge 2, let 𝒯S\mathcal{T}_S be the set of trees with vertex set SS. Let 𝒲S=Sn−2\mathcal{W}_S = S^{n-2} be the set of sequences of length n−2n - 2 with entries in SS.
  2. Lemma A: if TT is a tree with at least two vertices and ℓ\ell is a leaf, then T−ℓT - \ell is a tree. Here T−ℓT - \ell removes ℓ\ell and its edge.
  3. Proof of Lemma A. A cycle of T−ℓT - \ell would be a cycle of TT, so T−ℓT - \ell is acyclic. It has the vertex adjacent to ℓ\ell.
  4. Let x,y≠ℓx, y \ne \ell. By every walk contains a path, TT has a path from xx to yy. An inner vertex of a path has two distinct neighbours on it, so ℓ\ell is not on this path.
  5. So the path lies in T−ℓT - \ell, and T−ℓT - \ell is connected. This proves Lemma A.
  6. Define π(T)∈𝒲S\pi(T) \in \mathcal{W}_S for T∈𝒯ST \in \mathcal{T}_S by recursion on nn. If n=2n = 2, let π(T)\pi(T) be the empty sequence.
  7. If n≥3n \ge 3, let ℓ\ell be the smallest leaf of TT, which exists by the leaf lemma, and let aa be its neighbour. Let π(T)=(a,π(T−ℓ))\pi(T) = (a, \pi(T - \ell)), using Lemma A.
  8. Unwinding the recursion gives exactly the process that defines the Prüfer sequence. So for S={1,…,n}S = \set{1, \dots, n}, π(T)\pi(T) is the Prüfer sequence of TT.
  9. Lemma B: each vertex xx of T∈𝒯ST \in \mathcal{T}_S appears exactly deg⁡(x)−1\deg(x) - 1 times in π(T)\pi(T). We prove it by induction on nn.
  10. If n=2n = 2, TT has one edge, both vertices have degree 11, and π(T)\pi(T) is empty.
  11. Let n≥3n \ge 3, with ℓ,a\ell, a as in step 7 and T′=T−ℓT' = T - \ell. The vertex ℓ\ell has degree 11, and it does not appear in π(T)\pi(T), since a≠ℓa \ne \ell and ℓ\ell is not a vertex of T′T'.
  12. The vertex aa appears 1+(deg⁡T′(a)−1)=deg⁡T(a)−11 + (\deg_{T'}(a) - 1) = \deg_T(a) - 1 times, by the induction hypothesis. Every other vertex xx has deg⁡T′(x)=deg⁡T(x)\deg_{T'}(x) = \deg_T(x), and appears deg⁡T(x)−1\deg_T(x) - 1 times.
  13. Consequence of Lemma B: every vertex of TT has degree at least 11, since TT is connected with n≥2n \ge 2 vertices. So the leaves of TT are exactly the elements of SS that do not appear in π(T)\pi(T).
  14. Claim: for every SS with ∣S∣=n≥2\abs{S} = n \ge 2, the map π:𝒯S→𝒲S\pi : \mathcal{T}_S \to \mathcal{W}_S is a bijection. We argue by induction on nn.
  15. If n=2n = 2, say S={a,b}S = \set{a, b}, the only tree on SS has the single edge abab, because the graph with no edge is not connected. And 𝒲S\mathcal{W}_S has only the empty sequence.
  16. Let ∣S∣=n+1≥3\abs{S} = n + 1 \ge 3, and assume the claim for all sets of size nn. Let w=(w1,…,wn−1)∈𝒲Sw = (w_1, \dots, w_{n-1}) \in \mathcal{W}_S.
  17. The sequence ww has at most n−1n - 1 distinct entries, and SS has n+1n + 1 elements. Let ℓ\ell be the smallest element of SS that does not appear in ww.
  18. Let S′=S∖{ℓ}S' = S \setminus \set{\ell} and w′=(w2,…,wn−1)w' = (w_2, \dots, w_{n-1}). Then w′∈𝒲S′w' \in \mathcal{W}_{S'}. By the induction hypothesis, there is exactly one T′∈𝒯S′T' \in \mathcal{T}_{S'} with π(T′)=w′\pi(T') = w'.
  19. Existence. Let TT be T′T' with the new vertex ℓ\ell and the new edge ℓw1\ell w_1; note w1∈S′w_1 \in S'. Then TT is connected, since T′T' is connected and ℓ\ell is joined to w1w_1.
  20. A cycle in TT through ℓ\ell would give ℓ\ell two distinct neighbours, but ℓ\ell has degree 11. A cycle avoiding ℓ\ell would lie in T′T'. So TT is acyclic, and T∈𝒯ST \in \mathcal{T}_S.
  21. The vertex w1w_1 has degree at least 22 in TT: one edge in T′T' by step 13, and the edge to ℓ\ell. So w1w_1 is not a leaf of TT.
  22. Let x≠ℓ,w1x \ne \ell, w_1 be a leaf of TT. Then xx is a leaf of T′T', so xx does not appear in w′w' by step 13. Also x≠w1x \ne w_1, so xx does not appear in ww.
  23. By the choice of ℓ\ell in step 17, x>ℓx > \ell. So ℓ\ell is the smallest leaf of TT, with neighbour w1w_1, and T−ℓ=T′T - \ell = T'.
  24. By step 7, π(T)=(w1,π(T′))=(w1,w′)=w\pi(T) = (w_1, \pi(T')) = (w_1, w') = w.
  25. Uniqueness. Let Q∈𝒯SQ \in \mathcal{T}_S with π(Q)=w\pi(Q) = w. By step 13, the leaves of QQ are the elements of SS not in ww. The smallest of them is ℓ\ell.
  26. By step 7, the neighbour of ℓ\ell in QQ is w1w_1, and π(Q−ℓ)=w′\pi(Q - \ell) = w'. By Lemma A, Q−ℓ∈𝒯S′Q - \ell \in \mathcal{T}_{S'}. By step 18, Q−ℓ=T′Q - \ell = T'.
  27. So the edges of QQ are those of T′T' together with ℓw1\ell w_1. These are the edges of TT, so Q=TQ = T. This proves the claim.
  28. Take S={1,…,n}S = \set{1, \dots, n}. By the number of functions between finite sets, ∣𝒲S∣=nn−2\abs{\mathcal{W}_S} = n^{n-2}.
  29. By the claim and the bijection principle, the number of trees with vertex set {1,…,n}\set{1, \dots, n} is nn−2n^{n-2}.

Idea

Prüfer's code removes the smallest leaf again and again, and it writes down the neighbour of each removed leaf. A vertex is written deg⁡−1\deg - 1 times, so the leaves are exactly the labels that never appear. This lets us read off the first removed leaf from the code alone. Hence the code can be decoded step by step, and the tree can be rebuilt in exactly one way.

Reading path

To understand this page from the ground up, read these 70 pages in order. The foundations come first. The path takes the proofs Proof that a composition of injections is injective, Proof that a function is bijective iff it has a two-sided inverse, Proof of the rule of product, Proof of strong induction from ordinary induction, Proof that every finite tree with at least two vertices has a leaf, by a longest path, Proof of the number of functions between finite sets, Proof that a composition of surjections is surjective, Proof of the rule of sum, Proof that every walk contains a path, Proof of the bijection principle.

  1. Cardinality of a finite set definition
  2. Definition by recursion concept
  3. Element definition
  4. Graph definition
  5. Mathematical induction concept
  6. Natural numbers object
  7. Peano axioms concept
  8. Proposition concept
  9. Set definition
  10. Neighbourhood definition
  11. Walk definition
  12. Successor function definition
  13. Conjunction definition
  14. Implication definition
  15. Predicate definition
  16. Empty set object
  17. Ordered pair definition
  18. Degree of a vertex definition
  19. Intersection definition
  20. Path definition
  21. Reachability definition
  22. Trail definition
  23. Addition of natural numbers definition
  24. The successor function is injective statement
  25. Zero is not a successor statement
  26. Existential quantifier definition
  27. Universal quantifier definition
  28. Cartesian product definition
  29. Disjoint sets definition
  30. Subset definition
  31. Connected graph definition
  32. Circuit definition
  33. Order on the natural numbers definition
  34. Uniqueness quantifier definition
  35. Binary relation definition
  36. Cycle definition
  37. Proof of strong induction from ordinary induction proof
  38. Acyclic graph definition
  39. Function definition
  40. Strong induction statement
  41. Codomain definition
  42. Function composition definition
  43. Identity function definition
  44. Injective function definition
  45. Restriction of a function definition
  46. Tree definition
  47. Proof that every walk contains a path proof
  48. Surjective function definition
  49. Left inverse definition
  50. Right inverse definition
  51. Proof that a composition of injections is injective proof
  52. Proof that every finite tree with at least two vertices has a leaf, by a longest path proof
  53. Every walk contains a path statement
  54. Prüfer sequence definition
  55. Proof that a composition of surjections is surjective proof
  56. Bijective function definition
  57. Composition of injections is injective statement
  58. Every finite tree with at least two vertices has a leaf statement
  59. Composition of surjections is surjective statement
  60. Proof of the rule of sum proof
  61. Proof that a function is bijective iff it has a two-sided inverse proof
  62. Rule of sum statement
  63. Bijective iff it has a two-sided inverse statement
  64. Proof of the rule of product proof
  65. Proof of the bijection principle proof
  66. Rule of product statement
  67. Bijection principle statement
  68. Proof of the number of functions between finite sets proof
  69. Number of functions between finite sets statement
  70. Proof of Cayley's formula by Prüfer sequences proof

Where this leads

1 page builds on this one.

Further reading

  1. Web https://sites.lafayette.edu/bloomjs/files/2016/03/Cayleys-formula.pdf
About this page
Tag900KK0PPYM
URIm2://900KK0PPYM
Kindproof
WritingW0 stub
MSC05C30
ProvesCayley's formula
UsesTree, Prüfer sequence, Every finite tree with at least two vertices has a leaf, Connected graph, Acyclic graph, Cycle, Every walk contains a path, Path, Degree of a vertex, Number of functions between finite sets, Bijection principle
Changed4 November 2026

Markdown · JSON · Edit on GitHub

What this page needs for W1

  • an inventory row: the row of the inventory that the node accounts for (0 of 1)
  • a source with a locator (0 of 1)

The writing levels say how complete the text of a page is. They do not measure its truth.

What links here

No page links to this page yet.