Pr & amp; #252; fer encoding and Cayley Formula

Source: Internet
Author: User

Pr & #252; fer encoding and Cayley Formula
The number of trees whose vertices pass through the formula of Pr ü fer encoding and the formula of Cayley is equal to n ^ (n-2)

Today, I encountered a problem: in a n-level full graph, the number of all the spanning trees is n's N-2 power, think for a long time did not come up, or found on the Internet...
Simply put:
One-to-one correspondence method:
Assume that T is one of the trees, and the leaf has the smallest number. Set it to a1. The adjacent point of a1 is b1, And the a1 point is eliminated.
And edge (a1, b1). b1 points become the vertices of the remaining tree T1 after elimination. In the remaining tree T1, find the leaf with the smallest number, and set
A2, a2 Neighbor Contact b2, remove a2 and edge (a2, b2) from T1. This step continues the N-2 until the last one left
The edge ends. Therefore, a tree T corresponds to a sequence.
B1, b2 ,..., B [N-2]
Recovery tree T:
Sequence I 1, 2 ,... N
Sequence II b1, b2 ,..., B [N-2]
In I, find the first number that does not appear in II. It is obviously a1, the connection edge (a1, b1). In I, a1 is eliminated and II is eliminated.
To repeat the N-2 in this step, the two numbers in sequence I form the last edge.

The following is a blog from Matirx67.

The ayley formula is to say that a complete graph K_n has n ^ (n-2) trees, in other words, n ^ (n-2) trees with labels of n nodes. A very simple proof of the Cayley formula is dependent on the prüfer encoding, which is a method of coding with a labeled roottree.
Given a non-root tree with a label, find the leaf node with the smallest number, write down the number of the node adjacent to it, and then delete the leaf node. Perform this operation repeatedly until there are only two nodes left. Because of the total number of nodes n> 2 of the tree there are leaf nodes, so a n-node rootless tree uniquely corresponds to a series of length for N-2, each number in a series is within the range of 1 to n. Below we only need to explain, any length of N-2, the value range between 1 to n series are unique corresponds to a n node of rootless tree, in this way, the non-root tree with a label will form a one-to-one correspondence relationship with the Pr ü fer encoding, And the Cayley formula will be self-evident.
When I see this, I suggest you draw a picture on your own and the result will be displayed (this sentence is my suggestion, not the original Matrix67 ).
Note that if A node A is not A leaf node, it has at least two edges. However, after the above process, the entire graph has only one edge, therefore, at least one adjacent node of node A has been removed, and the number of node A will appear in the Pr ü fer code corresponding to this tree. In turn, the numbers that appear in the prüfer encoding are obviously not the leaves of this tree (at the beginning. So we can see that the numbers that have not appeared in the prüfer encoding are exactly the leaf nodes of this tree (at the beginning. Find the smallest one (for example, ④) in the number that has not been seen. It is the leaf adjacent to the node (for example, ③) identified by the first number in the Pr ü fer code. Next, let's recursively consider the next n-3 bit encoding (don't forget that the total length of the encoding is N-2): Find out the smallest number not in the back n-3 bit encoding (7 in the example on the left ), connect it to the node corresponding to the total code 2nd (in this example, it is still ③ ). Next, find out the smallest number of non-contained n-4 bit encoding except 4 and 7, do the same processing ...... In turn, connect ③ ② ⑤ 6 to the node represented by 3rd, 4, 5, 6, and 7 characters in the code. Finally, we still have 1. We haven't processed the token. Just connect them directly. Since the total number of nodes that have not been processed is 2 longer than the remaining encoding length, we can always find a minimum number that does not appear in the remaining encoding, and the algorithm can always proceed. In this way, any prüfer code uniquely corresponds to a rootless tree, and the number of N-2 bit prüfer encoding has many rootless trees with labels.

An interesting promotion is that the degrees of n nodes are D1, D2 ,..., Total rootless tree of Dn (n-2 )! /[(D1-1 )! (D2-1 )!.. Dn-1 )! Because the number I in the prüfer encoding happens to appear Di-1 times.


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.