Prüfer sequence (source code)

= Prüfer sequence
{wiki=Prüfer_sequence}

A Prüfer sequence is a way to encode a labeled tree with \\( n \\) vertices into a unique sequence of length \\( n-2 \\). This sequence provides a convenient method for representing trees and has applications in combinatorics and graph theory. Here’s how a Prüfer sequence works: 1. **Definition of a Tree**: A tree is a connected acyclic graph. For \\( n \\) vertices, a tree has exactly \\( n-1 \\) edges.