How many labeled trees are there if there're $4$ leaves that are set?

1k Views Asked by At

Let $T=(V,E)$ be a tree of $10$ labeled nodes numbered $1,2,3,\dots,10$ such that there're $4$ labeled leaves $1,2,3,4$ (there may be more leaves in addition to $1,2,3,4$). How many such trees are there and how many trees are there where the leaves are only $1,2,3,4$?

I'll start with the second part. If there're exactly $4$ leaves then for every node except for nodes $1,2,3,4$ we have: $$2\le \deg(v)\le 4$$ because if $\deg(v)=1$ then it's an additional leave and if $\deg(v)>4$ then there're more than $4$ leaves.

According to the handshaking lemma: $$ \sum_{v\in V}\deg(v)=2|E|=2(|V|-1)=18 $$ We now need to find all possible combinations with repetitions of integers $2,3,4$ over $6$ bins ($6$ nodes remain after removal of $4$ leaves) such that their sum is $18-4=14$: $$ x_1+x_2+x_3+x_4+x_5+x_6=14,\quad 2\le x_i\le 4 $$ which can be solved using generating functions: $$ (x^2+x^3+x^4)^6=14\\x^{12}(1+x+x^2)=14 $$ so we need to find the coefficient of $x^{2}$ in: $$ \bigg(\frac{1-x^3}{1-x}\bigg)^6=\sum_{k=0}^6{6\choose k}(-1)^kx^{3k}\cdot \sum_{i=0}^{\infty}{i+5\choose i}x^6 $$ but it's impossible to find the coefficient from this because the powers of $x$ are too high.

I would've multiplied the result by $6!$ to account for order but I'm obviously doing something wrong.

And regarding the first part I would've found the number of labeled trees with at least the leaves $1,2,3,4$ by first choosing some ${6\choose 3}$ from $6$ nodes that are not $1,2,3,4$ and then using the same approach as above to count all combinations with repetitions and then subtract all that from the total $n^{n-2}$ possible labeled trees.

2

There are 2 best solutions below

3
On BEST ANSWER

For a labeled tree on $n$ vertices the count of those where the first $m$ are leaves is obtained using Pruefer codes, which have the property that the degree of a vertex in the tree resulting from the code is one more than the number of times it appears in the code. Thus the fact that the $m$ nodes are leaves means they do not appear in the Pruefer code. Hence there remain

$$(n-m)^{n-2}$$

possible codes. If these $m$ leaves are the only ones all the other nodes must appear in the Pruefer code. We get using Stirling numbers

$$(n-m)! \times {n-2\brace n-m}.$$

Remark. I noticed the link to the OEIS only now where OP says they are not familiar with Stirling numbers. I trust the Wikipedia entry on Pruefer codes is sufficient. With the Stirling numbers we partition the $n-2$ slots in the Pruefer code into sets for the $n-m$ values, which correspond to the nodes and are then guaranteed to appear at least once. Here we have ordered set partitions however and hence the multiplier of $(n-m)!.$ E.g. when we fill four slots with two values $1$ and $2$ and have a set partition into two sets namely $\{1,3\}$ and $\{2,4\}$ then placing $1$ in the former and $2$ in the latter slots is not the same as $2$ in the former and $1$ in the latter. The fact that Stirling numbers count unordered set partitions into into non-empty sets is all we need to know here.

Addendum. OP asks for clarification of closed form at OEIS A055316. Explanation is simply that OEIS lists the formula for the number of trees having exactly $m$ leaves, as opposed to trees where nodes $1$ to $m$ are the set of leaves. This means we need to choose the $m$ leaves from the $n$ nodes first, getting

$${n\choose m} \times (n-m)! \times {n-2\brace n-m} = \frac{n!}{m!} \times {n-2\brace n-m}.$$

1
On

The generating functions are overkill for finding out how 6 numbers which are all 2, 3, or 4 can add up to 14. At minimum, six such numbers sum to 12, so you have 2 excess: either one 4 and five 2s, or two 3s and four 2s.

In the first case, you have four arms from a single vertex of degree 4, and you can vary the lengths of the arms for a total of 10 vertices. In the second case, you have two vertices of degree three connected by a path with zero to four vertices of degree 2, and the remaining two neighbors of each of the degree-3 vertices begin four arms to the leaves.

As far as the generating functions go, there seems to be a missing power of 6 in this line:

$$x^{12}(1+x+x^2)=14$$

but I think that was corrected in the following lines.