Cayley's formula 2026-10-14
For an integer , let be the set of labelled trees with fixed vertex set . Each tree is a finite simple graph, with no distinguished root of a tree, and two trees are different exactly when their sets of edges differ. Then
Equivalently, this is the number of spanning trees of the complete graph . The labelled combinatorial structure includes the fixed labels: drawings, positions, and the order in which edges are listed do not create extra trees. For , the single vertex with no edges is the unique tree; count it separately, since the Prüfer sequence construction requires . For , the unique tree has edge and corresponds to the empty Prüfer sequence. [ref]
For four fixed labels, there are labelled trees, but only two unlabelled trees: the star graph and the path graph. There are four star graphs, one for each choice of centre. There are path graphs: arrange the labels along a graph path, then identify each ordering with its reversal, which describes the same set of edges. Thus . For instance, star graphs centred at and at have different sets of edges even though they have the same shape.
Figure 1.
All sixteen labelled trees on four fixed vertices: four star graphs and twelve path graphs, each with its Prüfer sequence
. Details.
The striking point is that connectedness and the absence of a graph cycle are global restrictions on edges, yet the answer is a power with no correction factor. The Prüfer sequence supplies a bijection that turns those restrictions into freely chosen labels. The rule of product then gives immediately. The same representation makes vertex degrees easy to count and supports uniform labelled tree generation for simulations and algorithm experiments.
Arthur Cayley's 1889 paper "A theorem on trees", published in the Quarterly Journal of Pure and Applied Mathematics, volume 23, pages 376–378, treats the counting problem and its refinement by vertex degrees. It was reprinted as paper 895 in volume XIII of his Collected Mathematical Papers, pages 26–28. This publication is the historical context for the name Cayley's formula; the name alone is not a claim of priority. [ref] [ref]
Labelled tree 2026-10-14
A tree whose vertices carry distinct labels from a fixed finite set, as a labelled combinatorial structure. Two labelled trees on the same vertex set are equal when their sets of edges are equal: any comparison must keep every label fixed. Cayley's formula counts these trees.
For and positive integers with , the number of labelled trees having vertex degree at label is
By the Prüfer degree formula, this is the multinomial coefficient counting sequences with occurrences of each label. If a degree is zero or the sum is wrong, there are no such trees. For the example degree sequence , there are labelled trees, one for each ordering of the labels . Knowing the vertex degrees thus constrains, but usually does not determine, the tree.
Prüfer degree formula 2026-10-14
For a labelled tree with vertices, the vertex degree of label is one plus the number of occurrences of in its Prüfer sequence:
Each recording of corresponds to an incident edge removed when a neighbouring leaf of a graph is deleted. Exactly one incident edge remains when itself is deleted, or when it belongs to the final pair. In particular, is a leaf of a graph exactly when it never occurs in the Prüfer sequence. The same reasoning applies to each remaining tree and its remaining code. [ref]
For , the occurrence counts in label order are , giving the degree sequence . Its sum is , as required by the degree-sum formula. More generally, summing the occurrence counts gives , so summing the vertex degrees gives .
Prüfer sequence 2026-10-14
For , a Prüfer sequence is the encoding of a labelled tree on by a sequence
Repeated labels are allowed, and their order matters. To encode the tree, repeatedly remove its smallest-labelled leaf of a graph together with its incident edge, recording the label of its unique neighbour. Stop when two vertices remain; do not record their final edge. Removing a leaf of a graph leaves a tree, so the procedure makes exactly deletions. The choice of the smallest label makes the encoding deterministic. [ref]
For a concrete example, take six vertices and the set of edges
Initially label the vertices of vertex degree one. Remove and record its neighbour . Now has become a leaf of a graph, so remove and record . Next remove and record again; then remove and record . The final edge joins and . Thus the Prüfer sequence is
The deletion order is : removing a leaf of a graph can make its neighbour a leaf of a graph, so the eligible labels change as the tree shrinks.
Figure 1.
Encoding a six-vertex tree as the Prüfer sequence , then reconstructing its five edges
. Details.
To decode, keep a set of remaining labels, initially , and the remaining sequence, initially . While the sequence is nonempty, let be the smallest label in absent from the entire remaining sequence. Add an edge between and its first entry, then remove from and delete that first entry. Finally join the two labels left in . For the example:
Remaining sequence before the stepSmallest absent remaining labelEdge added
Empty; Final pair
The decoder always has a choice: if the remaining sequence has length , then has labels, so at least two of them are absent. Its first entry is still in , and differs from the chosen absent label. Every removed vertex attaches to a vertex that survives longer; following these attachments eventually reaches the final pair. Consequently the decoded graph is connected, and its edges make it a tree. In this construction, each occurrence of contributes an incident edge, and gets one more edge at its final attachment. Thus a remaining label is absent from the remaining sequence exactly when it labels a leaf of a graph. Encoding and decoding choose the same smallest label at each step and undo each other. This bijection proves Cayley's formula and explains why every freely chosen sequence is valid. [ref]
For there is exactly one empty sequence, and decoding adds the sole edge. For there is one tree, with vertex degree zero, but no length- Prüfer sequence. This is the exception both to the encoding convention and to the Prüfer degree formula.
Heinz Prüfer's 1918 paper "Neuer Beweis eines Satzes über Permutationen" appeared in Archiv der Mathematik und Physik, third series, volume 27, pages 142–144. It gives an encoding proof of the labelled tree count. The historical title means "New proof of a theorem on permutations"; the modern Prüfer sequence permits repeated labels, so it is not a permutation. [ref]
For , choose independent random variables, each with the uniform distribution on a finite set , and decode their values as a Prüfer sequence. Every sequence has probability , and the bijection gives each labelled tree the same probability. This produces a uniform spanning tree of the complete graph without repeatedly proposing sets of edges and rejecting those that fail to be trees. It supplies random inputs for testing implementations of breadth-first search and a tractable model of random connections. [ref]
This distribution is uniform over fixed-label trees, rather than over unlabelled trees. With four labels, the star graph shape has probability and the path graph shape has probability . Also, for a fixed label , the Prüfer degree formula gives
Here the binomial distribution counts the independent code positions equal to . The expected value agrees with the average vertex degree from the degree-sum formula. Individual labels have the same distribution by symmetry, though their vertex degrees are constrained together by their fixed sum. When , simply return the single isolated vertex.
Unlabelled tree 2026-10-14
A tree considered up to graph isomorphism, with vertex names ignored. For example, all four labelled trees that are star graphs on represent one unlabelled tree. Dividing the total in Cayley's formula by does not count unlabelled trees: different shapes can have different numbers of distinct labellings.