TheoremComplete

Trees and Networks - Main Theorem

Cayley's Formula counts the number of labeled trees, revealing a surprising connection between trees and sequences.

DefinitionCayley's Formula

The number of labeled trees on nn vertices is nnβˆ’2n^{n-2}.

Proof via PrΓΌfer Sequences:

We establish a bijection between labeled trees on {1,2,…,n}\{1, 2, \ldots, n\} and sequences of length nβˆ’2n-2 with elements from {1,2,…,n}\{1, 2, \ldots, n\}. There are nnβˆ’2n^{n-2} such sequences.

Tree to Sequence (Encoding): Given a labeled tree TT on nn vertices:

  1. Find the leaf with smallest label, say β„“\ell
  2. Add the label of β„“\ell's neighbor to the sequence
  3. Remove β„“\ell from the tree
  4. Repeat steps 1-3 until only 2 vertices remain

This produces a sequence of length nβˆ’2n-2 called the PrΓΌfer sequence.

Sequence to Tree (Decoding): Given a sequence s1,s2,…,snβˆ’2s_1, s_2, \ldots, s_{n-2} of elements from {1,…,n}\{1, \ldots, n\}:

  1. Start with isolated vertices {1,2,…,n}\{1, 2, \ldots, n\}
  2. For i=1i = 1 to nβˆ’2n-2:
    • Find smallest vertex β„“\ell not yet connected and not appearing in si,si+1,…,snβˆ’2s_i, s_{i+1}, \ldots, s_{n-2}
    • Connect β„“\ell to sis_i
  3. Connect the two remaining isolated vertices

This produces a unique tree.

Verification: We must show this is a bijection:

Well-defined: The encoding always produces a sequence (we can always find a leaf until 2 vertices remain). The decoding produces a connected acyclic graph (tree).

Inverse: Decoding(Encoding(TT)) = TT and Encoding(Decoding(ss)) = ss. This can be verified by tracking which vertices appear in the sequence (exactly those with degree β‰₯2\geq 2, appearing deg(v)βˆ’1(v) - 1 times).

Bijection: Since encoding and decoding are inverses, we have a bijection.

Therefore, the number of labeled trees equals nnβˆ’2n^{n-2}. β–‘\square

ExampleSmall Cases

For n=3n = 3: 33βˆ’2=33^{3-2} = 3 trees. They are:

  • Edge set {{1,2},{2,3}}\{\{1,2\}, \{2,3\}\} (path 1-2-3)
  • Edge set {{1,3},{2,3}}\{\{1,3\}, \{2,3\}\} (path 1-3-2)
  • Edge set {{1,2},{1,3}}\{\{1,2\}, \{1,3\}\} (path 2-1-3)

PrΓΌfer sequences: (2),(3),(1)(2), (3), (1) respectively.

For n=4n = 4: 44βˆ’2=164^{4-2} = 16 trees (4 paths, 3 stars with each vertex as center, etc.).

Remark

Cayley's formula has numerous proofs: matrix-tree theorem (via determinants of Laplacian matrices), double counting using rooted trees, and probabilistic proofs using random walks. The formula extends to counting spanning trees of KnK_n (complete graph), which also equals nnβˆ’2n^{n-2}. For counting spanning trees of arbitrary graphs, the matrix-tree theorem provides a determinant formula. Kirchhoff's theorem generalizes this to electrical networks. The PrΓΌfer sequence also reveals that in a random labeled tree, vertex ii has degree following a binomial-like distribution.