How many trees on $\{1,2,3,4,5,6,7\}$ have a vertex of degree 2 ?
Attempt -
It feels like an inclusion exclusion problem (using kailey's code) , let's define $|A_i| \Rightarrow $ vertex $i$ is of degree $1$.
$|Ai\, \cup A_j$| - vertices $i,j$ are of degree $1$ and so on.
So following my calculation we might get -
$7 \cdot 5\cdot 6^4 - \binom{7}{2}\binom{5}{2}\cdot2\cdot5^3+ \binom{7}{3}\binom{5}{3}\cdot3!\cdot4^2 - \binom{7}{4}\binom{5}{4}\cdot4!\cdot3 + \binom{7}{5}5!$
What do you think? thank you !
I think that your formula is correct. It gives $16380$. Below there is an alternative approach with the same final result.
For a labeled tree with $7$ vertices we have that $$\sum_{v \in \{1,2,3,4,5,6,7\}} \deg v = 2(7-1)=12.$$ So if a tree has NOT vertices of degree $2$ and it has $m$ leaves of degree $1$ then $$12\geq l+3(7-l)$$ which means that $l$ can be $5$ or $6$ (there is at least one vertex which is not a leaf). Hence the degree sequence is $$1,1,1,1,1,3,4\quad\text{or}\quad 1,1,1,1,1,1,6.$$ By Cayley's formula there are $7^{7−2}$ labeled trees with $7$ vertices and the number of trees with vertices $1,2,3,4,5,6,7$ of degrees $d_1, d_2,\dots, d_7$ is $$\binom{7-2}{d_1-1,d_2-1,\dots, d_7-1}.$$ Hence the number of trees with vertices $1,2,3,4,5,6,7$ have at least a vertex of degree $2$ is $$7^{5}-7\cdot 6\cdot\frac{5!}{2!3!}-7\cdot \frac{5!}{5!}=16380.$$