Calculate number of nodes in a tree from degrees

1k Views Asked by At

If I have a tree with the first $N$ nodes having degree $\{2, 3, 4,\dots, N+1\}$ and the remaining nodes having degrees of $1$, is it possible to calculate the total number of nodes?

I've no idea how to go about starting this.

I first thought I could try:

$ \sum_{k=1}^{N} k -1 = \frac{N(N+1)}{2} - 1$

for part of it before realising that degrees are the total number of edges that are incident to a vertex and not necessarily the number of edges that connect to its child nodes. So, there could be overlapping edges for the same nodes.

Edit: realised that I confused how you connect nodes in a tree with how you can connect them in a standard undirected graph. Ignore the final sentence.

2

There are 2 best solutions below

0
On BEST ANSWER

Let $n_d$ be the number of nodes of degree $d$. Then the total number of nodes is $$\sum_{d \ge 1} n_d = n_1 + \sum_{d=2}^{N+1} 1 = n_1 + N,$$ and the handshake lemma implies $$2(n_1 + N-1) = \sum_{d \ge 1} d n_d = n_1 + \sum_{d=2}^{N+1} d = n_1 + \frac{N(N+3)}{2},$$ so $$n_1 = \frac{N(N+3)}{2} - 2(N-1) = \frac{N^2-N+4}{2},$$ and the total number of nodes is $$n_1 + N = \frac{N^2+N+4}{2}.$$

2
On

My bad (again). You can't for generic graphs, but you can for trees. My graph that disproved it had a loop, so it wasn't a tree.

The formula is:

$$Nodes = \frac{N*(N+1)}{2} + 2$$