I was looking at the proof of the following result:
Let $n\geq 2$,the number of spanning trees in the complete graph $K_n$ is $n^{n-2}$.
The proof uses a bijection between $T$ ,the set of all spanning trees of $K_n$ and $A$, the set of all sequences $(a_1,a_2,...,a_{n-2})$ with $1\leq a_i\leq n$ for all $i$.The bijection is given by the Prufer code.
The forward map is clear to me.
We will look at all leaf nodes and pick the one with minimal numbering.Then we will delete the vertex and the associated edge and take a note of the neighboring vertex/node.We will continue in this way and finally we will end up getting two nodes connected with one edge.Thus we obtain $(a_1,a_2,...,a_{n-2})$.
For example,look at the following graph:
Then following the algorithm we get something like:
So,the Prufer sequence is $(1,8,3,1,4,4,8)$.
Now I am having problem in decoding the sequence and forming a tree.
The algorithm is to choose minimal $b_1\notin (a_1,a_2,...,a_{n-2})$ and join $b_1a_1$.Then take minimal $b_2\neq b_1 $ and $b_2\notin (a_2,a_3,...,a_{n-2})$ and join $b_2a_2$ ,then take minimal $b_3\neq b_1,b_2$ and $b_2\notin (a_3,a_4,...,a_{n-2})$ and join $b_3a_3$ and proceed in this way.
But applying this algorithm on $(1,8,3,1,4,4,8)$,I am not getting the same tree.
Can someone tell me where I am making the mistake?