Counting Labeled Trees Without Listing Them
A labeled tree is a connected acyclic graph whose vertices carry distinct labels. Cayley's formula says that the number on n labeled vertices is nn−2. It counts different edge arrangements, not different drawings of the same arrangement, and it applies once the label set is fixed.
A spanning tree of a graph uses all of that graph's vertices while selecting enough edges to be connected and acyclic.
In a complete graph every labeled tree on the vertex set is available as a spanning tree, so Cayley's count applies directly.
For a noncomplete graph, missing edges may rule out many labeled trees, so the formula cannot be used without checking availability.
One explanation of Cayley's formula uses Prüfer sequences. Each labeled tree on n vertices corresponds to a sequence of length n−2 whose entries are vertex labels. Since each position has n choices, there are nn−2 sequences. A vertex occurs in the sequence exactly one fewer time than its degree in the tree.
Use the formula symbolically first, then substitute. Check that the exponent is two less than the number of vertices, not the number of edges or the number of possible edges. When a degree restriction is present, translate it into a count of occurrences in the Prüfer sequence.
How many spanning trees does the complete graph K4 have?
Mark Yourself Question
- Grab a piece of paper and try this problem yourself.
- When you're done, check the "I have answered this question" box below.
- View the solution and report whether you got it right or wrong.
For labeled trees on 6 vertices:
- What is the length of the associated Prüfer sequence?
- How many labeled trees are there?