Prüfer Codes and Labeled Trees
Prüfer codes encode a labeled tree by a sequence whose length is two less than the vertex count. Every sequence on those labels is valid.
- Source
- Anbloq
- Language
- English
- Created
- Updated
- Chapters
- 1
- Reading time
- 1 min
At each step remove the smallest labeled leaf and record its neighbor. For decoding, the smallest label absent from the remaining sequence is the next leaf. Attach it to the first sequence entry, remove both the leaf from consideration and that entry from the sequence, then continue. Connect the final two vertices.
\[\#\{\text{trees on }[n]\}=n^{n-2}\qquad(n\ge2).\]
Degrees encoded as frequencies
A vertex appears in the sequence exactly one fewer times than its degree, because each recorded appearance removes one incident edge before its own last edge. A constant sequence therefore gives a star centered at that repeated vertex. Matrix–tree counts spanning trees when only certain edges are allowed.[1]