Extremal trees with fixed degree sequence

The greedy tree $\mathcal{G}(D)$ and the $\mathcal{M}$-tree $\mathcal{M}(D)$ are known to be extremal among trees with degree sequence $D$ with respect to various graph invariants. This paper provides a general theorem that covers a large family of invariants for which $\mathcal{G}(D)$ or $\mathcal{M}(D)$ is extremal. Many known results, for example on the Wiener index, the number of subtrees, the number of independent subsets and the number of matchings follow as corollaries, as do some new results on invariants such as the number of rooted spanning forests, the incidence energy and the solvability. We also extend our results on trees with fixed degree sequence $D$ to the set of trees whose degree sequence is majorised by a given sequence $D$, which also has a number of applications.


introduction
In the context of chemical graph theory, (molecular) graphs are used to model molecules: the vertices of the graph represent the atoms of the molecule, and the edges correspond to the chemical bonds between atoms. Thus vertex degrees amount to valencies of atoms. If the entries of D = (d 1 , d 2 , . . . , d n ) are possible valencies of atoms, then the set of all graphs with degree sequence D contains the molecular graphs of all possible isomers of a certain molecule. This is one of the motivations to study graphs with a given degree sequence. In this paper, we will be particularly concerned with trees whose degree sequence is given.
The greedy tree G(D) with degree sequence D, formally defined in the next section, is a tree that can be constructed by starting with the largest degree vertex and always assigning the largest available degree to a neighbour of the vertex with the largest degree whose neighbour degrees are not yet fully specified. On the other hand, large degrees and small degrees alternate in the M-tree M(D) with degree sequence D, see Definition 3.3.
The greedy tree G(D) and the M-tree M(D) are known to be extremal for a number of graph invariants. Let us list a few examples.
• The sum W (G) of the distances d(u, v) between all (unordered) pairs of vertices {u, v}, better known as the Wiener index, is among the most popular graph invariants. It was shown by Wang in [33] and by Zhang et al. in [41] that, among all trees with degree sequence D, G(D) has the minimum Wiener index.
• Schmuck et al. [29] showed a more general statement: if W (G) is replaced by a Wiener-like invariant for a nonnegative and nondecreasing function f , then G(D) still attains the minimum value among trees with degree sequence D. Likewise, if f is a nonnegative and nonincreasing function, then G(D) attains the maximum value. In particular, this includes a well-studied invariant known as the Harary index, which corresponds to f (x) = 1/x (see [32]). • The greedy tree G(D) is extremal with respect to several other invariants including: the number of subtrees (and the number of antichains when rooted trees are considered) [3,42], -the spectral radius [5] and the Laplacian spectral radius [40], -the spectral moments [2,24]. See also [7] for a generalisation.
• The total number of independent subsets is also known as the Merrifield-Simmons index of a graph. It is proven in [1] that the Merrifield-Simmons index is maximised by M(D). The total number of matchings is also called Hosoya index. It is minimised by M(D) (see [1]). • The energy of a graph G is defined as En(G) = i |λ i |, where the λ i s are the eigenvalues of the adjacency matrix of G. For trees, the energy is connected to matchings by the well-known Coulson formula [14]: let m(G, k) be the number of matchings of cardinality k in a graph G. For every tree T , It is shown in [1] that, among all trees with degree sequence D, M(D) is the unique tree with minimum M(., x) for any x > 0. Thus, it also has the minimum energy. The long list of graph invariants for which G(D) or M(D) is extremal leads us to the following natural question: what condition(s) does a graph invariant need to satisfy for G(D) or M(D) to be extremal among trees with degree sequence D? In this paper, we provide sufficient conditions that cover a number of examples, both old and new. The idea is inspired by an exchange lemma used to study bounded degree trees in [17], and trees with given degree sequence in [1].
A sequence B = (b 1 , b 2 , . . . , b n ) is said to majorise D if b 1 + · · · + b n = d 1 + · · · + d n and d 1 + · · · + d k ≤ b 1 + · · · + b k for every k with 1 ≤ k < n. We then write D ⊳ B. In Section 4, we will consider the set of all trees whose degree sequence is majorised by D. Several natural sets of trees satisfy majorisation properties. This includes the set of all n-vertex trees, n-vertex trees with bounded degrees, and trees of order n with fixed number of leaves. There are several instances of graph invariants for which the extremal trees with degree sequence D are also extremal among those whose degree sequence is majorised by D. We will see many such examples at the end of this paper.
We need to introduce some notation to describe our results. Let T be a rooted tree. The root of T is denoted by r(T ). We write T = [T 1 , T 2 , . . . , T k ] if the rooted trees T 1 , T 2 , . . . , T k are the connected components of T − r(T ), where the roots of T 1 , T 2 , . . . , T k are the neighbours of r(T ).
Let v and w be two different leaves of a tree H. The tree obtained by merging the root of [L 1 , L 2 , . . . , L k ] with v and the root of [R 1 , R 2 , . . . , R ℓ ] with w, as seen in Figure 1, is denoted by [L 1 , L 2 , . . . , L k ]vHw[R 1 , R 2 , . . . , R ℓ ]. Let ρ(T ) be a quantity associated to a rooted tree T , which satisfies a recursive relation of the form (2) ρ([T 1 , T 2 , . . . , T k ]) = f ρ (ρ(T 1 ), ρ(T 2 ), . . . , ρ(T k )) for a symmetric function f ρ , i.e., the value of f ρ is invariant under permutation of the branches. We call f ρ the recurrence rule for ρ. In our examples, the recurrence rule can always be expressed as a function of sums or products over all branches.
Definition 1.1. We say that a tree T is ρ-exchange-extremal if, whenever we can decompose T as We will prove the following theorem: Theorem. Let ρ be an invariant of rooted trees that satisfies the recurrence relation (2). Suppose that a tree T with degree sequence D is ρ-exchange-extremal.
• If f ρ is increasing (in each variable and under addition of further variables) and the minimum of ρ is attained by the single-vertex tree, then T has to be G(D). • If f ρ is decreasing (in each variable and under addition of further variables) and the maximum of ρ is attained by the single-vertex tree, then T has to be M(D).
It turns out that extremality with respect to many different invariants implies ρ-exchangeextremality for a suitable choice of ρ. This includes some of the previously mentioned instances (Wiener index, number of subtrees, Merrifield-Simmons index, Hosoya index, etc.), but we will also discuss examples that have not been considered before.
The rest of this paper is organised as follows. Section 2 treats the case of increasing f ρ , where the greedy tree G(D) is extremal. The case of decreasing f ρ is considered in Section 3, it leads to the situation where the M-tree M(D) is extremal. Various special cases are listed at the end of each section. This includes many known results, but we also obtain several new results, specifically for the number of rooted spanning forests (related to the coefficients of the Laplacian characteristic polynomial), the incidence energy, and an invariant called the solvability. We also settle an open question on the Steiner Wiener index. Furthermore, in Section 4, we compare trees with different degree sequences and prove extremality results for the set of all trees whose degree sequence is majorised by a fixed sequence D.
The following technical terms will be needed. The height h(T ) of a rooted tree T is the greatest distance of a vertex from r(T ). A subgraph B of a tree T is called a complete branch of T if there is an edge e such that B is one of the components of T −e, see Figure 2. We denote by rd(B) the degree of the root r(B) (the end of e that belongs to B) as a vertex of B.

2.
Increasing recurrence rule f ρ Definition 2.1. [29] Given a degree sequence of a tree D, the greedy tree, denoted G(D), is constructed by the following "greedy algorithm": (i) Label the vertex with the largest degree v (the root).
We will see in this section that the greedy tree is the unique ρ-exchange-extremal tree if ρ satisfies the following conditions: I.1 the recurrence relation (2) holds, for some symmetric recurrence rule f ρ , I.2 the function f ρ is strictly increasing (strictly increasing in each single variable and strictly increasing under addition of further variables), tree.
2.1. Special case: the Wiener index. Let us first consider the special case where ρ(T ) is the number of vertices of T , i.e., ρ(T ) = ρ 0 (T ) = |V (T )|. We have The recurrence rule f ρ 0 is indeed symmetric and increasing with respect to each of its variables and under addition of further variables. Clearly ρ 0 (•) = 1 is the minimum among all rooted trees. So conditions I.1 to I.3 are all satisfied. Now recall that the Wiener index is the sum of all distances between pairs of vertices: An important alternative formula for the Wiener index for trees is (see [9]) where T u and T v are the components of T −uv containing u and v respectively. We use this formula to show that minimality with respect to the Wiener index implies ρ 0 -exchangeextremality.
Lemma 2.2 (cf. [31]). Let T be a tree with degree sequence D for which W (T ) attains its minimum. Then, for any two disjoint complete branches Proof. Let P = r(A)u 1 . . . u t r(B) be the unique path between r(A) and r(B). To simplify notation, we put α = ρ 0 (A) = 1 + k i=1 ρ 0 (A i ) and β = ρ 0 (B) = 1 + ℓ i=1 ρ 0 (B i ). For 1 ≤ j ≤ t, let U j be the component containing u j when we remove all the edges of the path P , and set z j = ρ 0 (U j ), p j = z 1 + · · · + z j , q j = z t + · · · + z t−j+1 and p 0 = q 0 = 0.
Using the formula for the Wiener index in (3), we have: where C T is the contribution of edges in U 1 , . . . , U t , A and B.
With q = q 1 + · · · + q t and p = p 1 + · · · + p t , this can be rewritten as The last two terms t j=0 p j q t−j + C T are invariant under any rearrangements of the A i s and B i s. Note that the degree sequence remains the same if all the A i s are switched with all the B i s (interchanging the degrees of r(A) and r(B)), if A 1 , A 2 , . . . , A k , B 1 , B 2 , . . . , B ℓ are permuted in an arbitrary way, or both. Hence, if W (T ) is minimal, then the expression αq + βp + αβ(t + 1) must have its minimum value under these operations. Note that the sum Σ = α + β remains constant under any of these rearrangements, and we have which is a strictly concave function of α. Thus the minimum is attained if α is either as small or as large as possible. For this we must have In words, the largest possible branches (and as many of them as possible) have to be gathered in one place. This is precisely the statement of the lemma.
We know now that the tree which minimises the Wiener index is ρ 0 -exchange-extremal. Moreover, ρ 0 -exchange-extremality is equivalent to the semi-regular property defined in Definition 4 of [29], where it is proved that such a tree is greedy. Thus we have the following observation, which will be the basis for the proof of the main theorem of this section. Theorem 2.3 (cf. [29,31]). If T is a ρ 0 -exchange-extremal tree, then T is a greedy tree.

Main result.
We require one more lemma before stating the main result. This lemma establishes a connection between ρ 0 and other invariants ρ.
Thus we have shown that ρ(A) ≥ ρ(B) implies ρ 0 (A) ≥ ρ 0 (B), and the proof of the converse is analogous. Now we are ready for the main theorem.
Theorem 2.5. Let ρ be an invariant of rooted trees that satisfies I.1,I.2 and I. 3. If a tree T is ρ-exchange-extremal, then T is a greedy tree.
Proof. By Lemma 2.4, the tree T is also ρ 0 -exchange-extremal. Theorem 2.3 gives us the desired result.
In the remainder of this section, we describe different applications of Theorem 2.5.
2.3. The number of subtrees. As a first example, we consider the number of subtrees (here, a subtree is any induced subgraph that is connected and thus again a tree). We will be able to show that there is a suitable function ρ such that a tree with the greatest possible number of subtrees among all trees with the same degree sequence is necessarily ρ-exchange-extremal. To this end, we need a technical lemma, which will also be useful later.

Moreover, we have uniqueness: if
a > b and the x i s are not all equal to 1, then ℓ = k and x σ(1) , . . . , x σ(k) are a permutation of x 1 , . . . , x k . If a = b, then either the same holds, or ℓ = n − k and x σ(1) , . . . , x σ(n−k) are a permutation of x k+1 , . . . , x n .
In words, Lemma 2.6 says that the maximum value is reached when we assemble the largest elements together in the same product.
Comparing the two possibilities, we see that We have strict inequality if a > b unless k = ℓ and all x i s are equal (in which case x σ(1) , . . . , x σ(k) are still a permutation of x 1 , . . . , x k ) or all x i s are equal to 1. The statement of the lemma follows.
The number of subtrees of a tree T is denoted by η(T ), and the number of subtrees of T containing the vertices v 1 , . . . , v ℓ is denoted by η(T, v 1 , . . . , v ℓ ). In the following lemma, we establish the necessary property to apply our main theorem.

Lemma 2.7. Let T be a tree with degree sequence D for which η(T ) attains its maximum. For any two disjoint complete branches
• or k ≤ ℓ and In other words, T is ρ-exchange-extremal with ρ(T ) = η(T, r(T )).
Proof. Consider a decomposition of T as [A 1 , . . . , A k ]vHw[B 1 , . . . , B ℓ ], for some tree H. Each subtree of T has to belong to one of the following types: • Subtrees which contain neither v nor w. Each subtree of this type is either in • Subtrees which contain v, but not w. By similar reasoning as in the second case, the number of these subtrees is • Subtrees which contain both v and w. This corresponds to subtrees of H which contain both v and w, to which induced subtrees of the A i s and B i s containing the respective roots can be attached. Thus, there are of them. In total we have As in the proof of Lemma 2.2, this must be maximal under all permutations of the A i s and B i s, possibly also switching the degrees of v and w. Note here that β T is not affected by any of these rearrangements. So the maximality of η(T ) depends only on α T .
Since all the quantities involved are positive and the factors 1 + η(A i , r(A i )) and 1 + η(B i , r(B i )) are even greater than 1, Lemma 2.6 applies. Thus we obtain the maximum of So we have established ρ-exchange-extremality with respect to ρ(T ) = η(T, r(T )), the number of root-containing subtrees. Moreover, if T can be decomposed as [T 1 , . . . , T k ], then which is increasing in all of its variables and under addition of further variables, so I.1 and I.2 hold. Moreover, the minimum of η(T, r(T )), which is trivially equal to 1, is only reached if T = •. Thus, I.3 holds as well, and Theorem 2.5 implies the following theorem, which was already established in [3,42]. 3,42]). Given a degree sequence, the corresponding greedy tree is the unique tree that maximises the number of subtrees.

Rooted spanning forests, incidence energy, Laplacian-energy-like invariant.
Let T be an n-vertex tree and A(T ) its adjacency matrix. The Laplacian matrix of T is is the characteristic polynomial of the Laplacian matrix. In 1967, Kel'mans [22] gave a combinatorial interpretation for the coefficients of the Laplacian characteristic polynomial as follows.
where F(T, k) is the set of all spanning forests of the tree T containing exactly k components and γ(F ) is the product of the number of vertices in each component of F .
The quantity γ(F ) can be interpreted as the number of ways to assign roots to the components of a forest F , and therefore c k (T ) is the number of k-rooted spanning forests of T (spanning forests with k components, where each component is rooted at one of its vertices).
Let us consider the polynomial in which we associate to every rooted spanning forest F a weight x λ(F ) , where λ(F ) is the number of components of F . Replacing x by −x in Theorem 2.9, we see that this polynomial is connected to the Laplacian matrix as follows: Note that the total number of rooted spanning forests in a tree T is equal to rf(T, 1). To avoid confusion as we also consider rooted spanning forests within rooted trees, we will refer to "marked" spanning forests rather than rooted spanning forests in the following, and call the components' roots "markers". We show that the invariant rf(·, x) fits our general scheme, thereby generalising the approach taken in [20], where trees with given maximum degree are considered.
We define an auxiliary quantity for rooted trees T , which is denoted f(T, x). It counts marked spanning forests F weighted with x γ(F )−1 , in which the root of T is also a marker of one of the forest's components. Note that f(T, x) also counts (weighted) spanning forests of T where all components, except the one containing the root of T , have a marker. Finally, we set .
for some tree H, and let x > 0. Suppose that rf(T, x) ≤ rf(T ′ , x) for every tree T ′ with the same degree sequence as T . Then • either k ≥ ℓ and • or k ≤ ℓ and To obtain an expression for rf(T, x), we consider the following cases for a marked spanning forest of T : .
. Using a similar reasoning as before, we get a contribution of Hence, we finally obtain . x)) remains constant when the A i s and B j s are rearranged, as does the sum We can now argue exactly as in the proof of Lemma 2.2. Write y = k i=1 ρ 1 (A i , x). For rf(T, x) to attain its minimum under all possible permutations of A i s and B i s, the function which is strictly concave in y, has to attain its minimum. This occurs when y is either as large or as small as possible. That is, • k ≥ ℓ and min{ρ 1 (A 1 , x), . . . , ρ 1 (A k , x)} ≥ max{ρ 1 (B 1 , x), . . . , ρ 1 (B ℓ , x)}, or • k ≤ ℓ and max{ρ 1 (A 1 , x), . . . , ρ 1 (A k , x)} ≤ min{ρ 1 (B 1 , x), . . . , ρ 1 (B ℓ , x)}.
We have established now that minimality with respect to rf(·, x) implies ρ 1 -exchangeextremality. Moreover, the quantity ρ 1 can be determined recursively as follows. If T can be decomposed as [T 1 , . . . , T k ], then using similar arguments as before. Thus, The recurrence rule f ρ 1 corresponding to (6) is increasing in all of its variables and under addition of further variables, moreover ρ 1 (•, x) = x 1+x is the unique minimum. So, we may use Theorem 2.5 to obtain the following result.   For a tree T , let µ 1 , µ 2 , . . . , µ n be the eigenvalues of L(T ). They are also the eigenvalues of the signless Laplacian matrix L + (T ) (this is in fact true for every bipartite graph, see [8]). Recall that the energy of a graph is the sum of the absolute values of the eigenvalues of its adjacency matrix. A variant of the energy, known as the Laplacian-energy-like invariant (LEL for short, see [27]), is defined by It is closely related to the incidence energy IE of a graph, defined in [21] as the sum of the singular values of its (vertex-edge) incidence matrix. For every tree T , one has LEL(T ) = IE(T ). Furthermore, it is known that (see [13]) where S(T ) is the subdivision graph of T . This allows us to prove the following corollary.
Corollary 2.15. Given a degree sequence of a tree, the incidence energy IE, or equivalently the Laplacian-energy-like invariant LEL, is minimised by the greedy tree.
Proof. Let T be a tree and S(T ) its subdivision graph. Using the Coulson formula (1) for the energy and the relation (7), we obtain: Thus, the claim readily follows from Corollary 2.14.

A common generalisation of Wiener index and terminal Wiener index.
In analogy to the Wiener index, the terminal Wiener index [12] is defined as the sum of all distances between pairs of leaves, and the spinal Wiener index [4] is the sum of all distances between pairs of non-leaves. It is known that both are minimised by greedy trees [4,31]. We consider a common generalisation defined as follows: for two fixed positive numbers a and b, we set where It is easy to see that W 1,1 is the Wiener index, W 1,0 is the terminal Wiener index, and W 0,1 is the spinal Wiener index. Let us prove an equivalent representation for W a,b that generalises (3).
where T v and T w are the components of T − vw containing v and w respectively. Proof. A pair of two vertices v ′ and w ′ occurs on the right side of the equation with weight ω(v ′ )ω(w ′ ) for every edge vw such that v ′ ∈ T v and w ′ ∈ T w (or the other way around). Equivalently, whenever the unique path P (v ′ , w ′ ) from v ′ to w ′ contains the edge vw. Every pair of two vertices v ′ and w ′ is counted d(v ′ , w ′ ) times in this way and therefore contributes ω(v ′ )ω(w ′ ) d(v ′ , w ′ ). The sum over all pairs gives the left side of the equation.
Let L(T ) be the set of leaves of a tree T . If T is rooted, the root is only counted as a leaf if it is the only vertex. In view of Proposition 2.16, we can write Proof. The proof is analogous to the one for the Wiener index (Lemma 2.2), using ρ 2 instead of ρ 0 .
In other words, a tree that minimises W a,b is ρ 2 -exchange-extremal. Moreover, if H = [H 1 , . . . , H k ], then We see that conditions I.1, I.2 and I.3 are satisfied for every fixed pair of positive numbers a, b. Hence, we have the following theorem: Theorem 2.18. Given a degree sequence D, W a,b is minimised by G(D) for every fixed pair of positive numbers a, b.
If we take the limits a → 0 or b → 0, we find that the greedy tree minimises W 0,b and W a,0 , thus in particular the terminal and the spinal Wiener index. However, it may not be the unique optimal tree, since strict inequalities may become non-strict in the limit. Let us, for example, exhibit this phenomenon for the terminal Wiener index W 1,0 . Consider the trees with degree sequence (3, 2, 2, 2, 2, 2, 1, 1, 1) shown in Figure 5.
The greedy tree T * T Figure 5. Optimal trees for the terminal Wiener index.
2.6. The Steiner Wiener index. The Steiner distance of a graph, introduced by Chartrand et al. [6] in 1989, is a natural and nice generalisation of the classical graph distance. For r ≥ 2, let v 1 , v 2 , . . . , v r be a set of vertices of a graph G. We denote by S(v 1 , v 2 . . . , v r ) the smallest subtree of G which contains all the vertices v 1 , v 2 , . . . , v r . Then the Steiner distance of {v 1 , . . . , v r }, denoted by sd(v 1 , v 2 , . . . , v r ), is the number of edges in S(v 1 , v 2 , . . . , v r ). For r = 2, the Steiner distance clearly coincides with the classical distance, i.e., sd(v 1 , v 2 ) = d(v 1 , v 2 ).
In [25], the authors define the Steiner r-Wiener index SW r (G) of a graph G as a generalisation of the Wiener index in the following way: It is straightforward that the case r = 2 corresponds to the classical Wiener index. We have SW 1 (G) = 0 for every graph G and SW n (G) = n − 1 for every n-vertex graph G, so it is natural to restrict r to the set {2, 3, . . . , n − 1}. There is also an alternative formula for the Steiner Wiener index of trees generalising (3), see [25]: Proposition 2.19. Let T be an n-vertex tree, and r a positive integer. We have where T u and T v are the components of T − uv containing u and v respectively.
Proof. Equation (9) is already proven in [25], and Equation (10)  1] asked in a recent paper whether the greedy tree minimises the Steiner r-Wiener index for every r. In the following, we will answer this question affirmatively. Recall for the following lemma that ρ 0 (T ) is simply defined to be the number of vertices of T . As for the Wiener index, we will show ρ 0 -exchange-extremality. To avoid degeneracies (see the example below), we consider SW r (T ) + εW (T ) for some fixed ε > 0 and later let ε go to 0. Proof. We use the same notation as in the proof of Lemma 2.2, see also Figure 4 again. We have where C T is invariant under permutations of the A i s and B i s. This is a strictly concave function of α, so it can only attain its minimum when α is either at its largest or smallest value. As in the proof of Lemma 2.2, this implies the statement.
We thus have the following theorem. As mentioned before, we now take the limit ε → 0 to obtain the following theorem.
Theorem 2.22. Given a degree sequence D, the greedy tree attains the minimum of the Steiner r-Wiener index SW r .
As was also the case previously for the terminal Wiener index and the spinal Wiener index, the greedy tree might not be unique with the minimum Steiner r-Wiener index. This can happen when r is quite large (compared to the total number of vertices), as in the following example: for the degree sequence D = (3, 2, 2, 1, 1, 1), both the greedy tree and the only other tree with the same degree sequence have the same Steiner 5-Wiener index of 27.

Greedy tree
Non-greedy tree

3.
Decreasing recurrence rule f ρ Let us first mention some definitions, which are needed to describe an M-tree. We use similar terminology and notation as in [1]. Let us remark that, even though large and small degrees alternate, the concept is slightly different from that of an "alternating greedy tree", as introduced in [35]. We simply write [d] for a pseudo-leaf branch with d vertices (a root and d − 1 leaves). In particular, [1] stands for a single vertex.
Definition 3.2. Let (d 1 , . . . , d t , 1, . . . , 1) be the degree sequence of a tree T , where d j ≥ 2 for 1 ≤ j ≤ t. The t-tuple (d 1 , . . . , d t ) is called the reduced degree sequence of T . We assume that the d i s are in non-increasing order, i.e., d 1 ≥ d 2 ≥ · · · ≥ d t .
By the handshake lemma, the sum of the number of leaves of T and the degrees of the non-leaf vertices, i.e., is the reduced degree sequence of T , is equal to 2(|L(T )| + t − 1). Thus, the number of leaves is |L(T )| = 2 − 2t + t i=1 d i . This implies that two trees with the same reduced degree sequence have the same number of leaves, therefore they have the same degree sequence.
Next, we give an explicit construction for the M-tree M(D) with degree sequence D. Following the previous remark, we also write M(D ′ ) instead of M(D) for the same M-tree, where D ′ is the reduced degree sequence corresponding to D.  [1], . . . , [1]]. We label selected vertices as shown in Figure 7, in such a way that At this point all non-leaf vertices are labelled.   3.1. Special case: the Hosoya index. Let T be a rooted tree, and recall that the Hosoya index, denoted by z(T ), is the total number of matchings of T . The number of matchings in T that do not cover the root r(T ) will be denoted by z 0 (T ). We consider the following ratio, which can be interpreted as the probability that a random matching does not cover the root: If T = [T 1 , . . . , T k ], then it is not hard to see that and It follows that .
Note that this recurrence rule f ρ 3 is symmetric and decreasing with respect to each of its variables and under addition of further variables. In addition, we obviously have ρ 3 (•) = 1 > ρ 3 (B) for every rooted tree B with more than one vertex. Thus II.1, II.2 and II.3 are all satisfied. In other words, the tree with degree sequence D that minimises the Hosoya index is ρ 3 -exchange-extremal. In addition, as a special case of Theorem 22 in [1], the following holds.

Main result.
In analogy to Theorem 2.5, we obtain the following result.
Theorem 3.6. Let ρ be an invariant of rooted trees that satisfies conditions II.1,II.2 and II.3. If a tree T is ρ-exchange-extremal, then T is an M-tree.
The proof of Theorem 3.6 is essentially identical to that of Theorem 2.5, with minor modifications to take into account that f ρ and f ρ 3 are decreasing and ρ(•) and ρ 3 (•) are maxima. The rest of this section will be devoted to applications of Theorem 3.6.

3.3.
Matching polynomial and energy. Let T be a rooted tree. Denote by m(T, k) the number of k-matchings in T and by m 0 (T, k) the number of k-matchings not containing the root. We write M(T, x) = k≥0 m(T, k)x k and M 0 (T, x) = k≥0 m 0 (T, k)x k for the generating polynomials corresponding to m and m 0 respectively. Moreover, we define the following ratio for x > 0: The tree that minimises the matching polynomial M(T, x) for some x > 0 is therefore τ (., x)-exchange-extremal. In addition, we have the following generalisation of (12): if T = [T 1 , T 2 , . . . , T k ], then .
The recurrence rule f ρ , with ρ(T ) = τ (T, x), is thus symmetric and decreasing with respect to each of its variables and under addition of further variables. In addition, τ (•, x) = 1 is the unique maximum among all rooted trees for every x. Thus the following result from [1] can be seen as a special case of Theorem 3.6: In view of the connection between the energy and the matching polynomial (namely the Coulson formula (1)), we also get the following corollary.

Merrifield-Simmons index.
Recall that the number of independent sets in T is also called the Merrifield-Simmons index and denoted by σ(T ). Let σ 0 (T ) be the number of independent sets of T that do not contain the root, and define ρ 4 (T ) = σ(T )/σ 0 (T ). The following lemma from [1] states that the tree that maximises the number of independent sets among all trees with a given degree sequence D has to be ρ 4 -exchange-extremal. • or k ≤ ℓ and max{ρ 4 (A j ) : 1 ≤ j ≤ k} ≤ min{ρ 4 (B j ) : 1 ≤ j ≤ ℓ}.
The recurrence rule f ρ 4 corresponding to ρ 4 is found in a similar way to (12), and is given by Note that it is decreasing with respect to each of its variables (and under addition of further variables), and ρ 4 (•) = 2 is easily seen to be maximal among all trees. Hence we can deduce the following theorem as a consequence of Theorem 3.6.
where A is the adjacency matrix of G and diag(a) is the diagonal matrix whose diagonal is a. This can be interpreted as a domination problem with parity constraints. We are looking for a set S of vertices satisfying, for each of the vertices of the graph, one of four possible conditions: the open/closed neighbourhood has to contain an even/odd number of vertices in S. Here, a encodes the open/closed neighbourhood condition and b encodes the required parity. The solvability of a graph measures how many instances of the problem have solutions. It turns out that the solvability of trees can be calculated by a recursion involving a second auxiliary quantity t associated with rooted trees, as stated in the following lemma.
We remark that the value of the parameter t generally depends on the choice of root, unlike s. Note also that s(T ) and t(T ) are both positive, and that s(T ) > t(T ) holds for every rooted tree T .
It was shown in [15] that the path has the greatest solvability among all trees (in fact all graphs) of a given order, while the star has the least solvability, but no other extremal results for the solvability of trees are available. Let us show that our general results apply to the solvability as well. To this end, define ρ 5 (T ) to be the ratio ρ 5 (T ) = s(T ) t(T ) > 1. If T can be decomposed as [T 1 , . . . , T k ], then by Lemma 3.12 we have: (14) ρ Note that this is a symmetric and decreasing recurrence rule, so ρ 5 satisfies conditions II.1 and II.2. Moreover, II.3 is also satisfied by (14), since for every tree rooted tree T with more than one vertex. Let us now prove the main lemma of this subsection.  Proof. Let P = u 0 u 1 . . . u m be the path between r(A) = u 0 and r(B) = u m . For 1 ≤ j < m, ] be the component containing u j (rooted at u j ) when we remove all the edges of the path P . We also denote by X j the component containing u j in T − u j−1 u j , rooted at u j . We consider the tree T as rooted at r(A). Using Lemma 3.12, we can write s(T ) and t(T ) in terms of matrices as follows: Moreover, for 1 ≤ j < m, we have Let us denote the 2 × 2-matrix on the right side of this equation by M j . Empty products (if rd(U j ) = 0) are defined to be 1, which is consistent with the recursion. Then we have  For m = 2, we have, since Suppose now that the statement is true for m = d. For the induction step, we take m = d + 1, and M(d and 5M 10 (d + 1) + 6M 11 (d + 1) This completes our induction. Since we know now that α and β are positive, and that ρ 5 (A 1 ), . . . , ρ 5 (A k ), ρ 5 (B 1 ), . . . , ρ 5 (B ℓ ) are all greater than 1 by definition, Lemma 2.6 applies and shows that s(T ) can only be minimal if • or α ≤ β, k ≤ ℓ and max{ρ 5 (A j ) : 1 ≤ j ≤ k} ≤ min{ρ 5 (B j ) : 1 ≤ j ≤ ℓ}. This completes the proof.
So a tree that minimises the solvability, given the degree sequence, must be ρ 5 -exchangeextremal. Applying Theorem 3.6, we immediately get the following theorem.
Theorem 3.14. Given a degree sequence of a tree D, the solvability is minimised by M(D).

Majorisation of degree sequences
We say that the sequence A = (a 1 , a 2 , . . . , a n ) majorises B = (b 1 , b 2 , . . . , b n ) if a 1 + a 2 + · · · + a n = b 1 + b 2 + · · · + b n and a 1 + a 2 + · · · + a k ≥ b 1 + b 2 + · · · + b k for all k with 1 ≤ k < n. In this case we write A ⊲ B. Let T n be the set of n-vertex trees. In this section we study the class of trees whose degree sequence is majorised by a fixed degree sequence B of a tree, i.e., Let ρ be an invariant of rooted trees which satisfies a recursive relation as in Equation (2), and let S n denote the set of permutations of 1, 2, . . . , n. We say that the tree invariant I is maximum-ρ-compatible if the following holds: For every tree H and every choice of two of its leaves v and w, every collection of rooted trees T 1 , T 2 , . . . , T r with ρ(T 1 ) ≥ ρ(T 2 ) ≥ · · · ≥ ρ(T r ), and every integer s with r/2 ≤ s ≤ r, the maximum value of I among all trees in the set (1) , . . . , T σ(k) ]vHw[T σ(k+1) , . . . , T σ(r) ] : σ ∈ S r and r − s ≤ k ≤ s} is attained by (at least) one of the following two trees: In words, among all possibilities to attach T 1 , T 2 , . . . , T r to v and w in such a way that their degrees are not greater than some fixed bound s + 1, the maximum value of I is reached when the s trees T i with largest ρ-values are attached to one of the two vertices v and w, so that its degree is s + 1. Note here that if s ≤ s ′ then K s ⊆ K s ′ . In the same way, one defines an invariant I to be minimum-ρ-compatible (replacing "maximum value" by "minimum value" in the definition).
Several examples from the previous sections fit this scheme. In each case, the proof is essentially the same as the proof that extremality with respect to I implies ρ-exchangeextremality.
• The Wiener index is minimum-ρ 0 -compatible, and this extends to the generalisations discussed in Subsections 2.5 and 2.6. • The solvability is minimum-ρ 5 -compatible (Subsection 3.5). We note that for any maximum-ρ-compatible invariant I, a tree with degree sequence D that attains the maximum value of I is necessarily ρ-exchange-extremal, since the compatibility condition is an extension of ρ-exchange-extremality. . . , b n ). Let r be the smallest index for which d r > b r (such an index must exist, since B and D have the same sum), and let ℓ be the largest index less than r such that d ℓ < b ℓ (such an index must exist, since b 1 + b 2 + · · · b r ≥ d 1 + d 2 + · · · + d r by majorisation). Observe that d i = b i for ℓ < i < r. Now define We note that B 1 is still non-increasing, thus a valid degree sequence: Moreover, it is easy to verify that D ⊳ B 1 , since b ′ i ≥ d i for i < r, while b ′ 1 + b ′ 2 + · · · + b ′ j = b 1 + b 2 + · · · + b j for j ≥ r. Clearly, we also have B 1 ⊳ B. We can repeat this procedure with B 1 and D to obtain a degree sequence B 2 with D ⊳ B 2 ⊳ B 1 , and so on. This yields a sequence of degree sequences B = B 0 , B 1 , B 2 , . . . , B p = D such that B = B 0 ⊲ B 1 ⊲ · · · ⊲ B p = D, and B i and B i+1 always only differ in two entries (by exactly 1 each). We therefore restrict ourselves first to the case that B and D only differ in two entries: b ℓ = d ℓ + 1, b r = d r − 1 and b i = d i for i / ∈ {ℓ, r}. Let v and w be distinct vertices in T such that d(v) = d ℓ ≥ d r = d(w). Then T can be decomposed as [T 1 , . . . , T d ℓ −1 ]vHw[T d ℓ , . . . , T d ℓ +dr−2 ] for some tree H and branches T 1 , T 2 , . . . , T d ℓ +dr−2 . Let σ ∈ S d ℓ +dr−2 such that ρ(T σ(1) ) ≥ ρ(T σ(2) ) ≥ · · · ≥ ρ(T σ(d ℓ +dr−2) ).
By the definition of maximum-ρ-compatibility, we can find a tree T ′ , which is either such that its degree sequence is B and I(T ) ≤ I(T ′ ). In the general case, we can find a sequence of trees T 0 , T 1 , . . . , T p = T whose degree sequences are B = B 0 , B 1 , . . . , B p = D respectively, such that I(T 0 ) ≥ I(T 1 ) ≥ · · · ≥ I(T p ) = I(T ).
This shows that the extremal tree E mentioned earlier can indeed be chosen to have degree sequence B. The statement of the theorem follows. Proof. The degree sequence condition implies that A ⊆ T ⊳B , so the statement is immediate from Theorem 4.1.
We conclude this paper by discussing different applications of Corollary 4.2.
• The first example is the class of all trees of order n, A = T n , where we can take B = (n − 1, 1, . . . , 1). The only tree with this degree sequence is the star S n = G(B) = M(B). Therefore, we obtain the following known results as immediate corollaries: among all n-vertex trees, the star minimises the Wiener index [9], the Hosoya index and the energy [11], the quantity rf(T, x) [43] for every x > 0 (thus also the incidence energy) and the solvability [15], while it maximises the number of subtrees [30] and the Merrifield-Simmons index [28].
• Next, we take A to be the set of all n-vertex trees whose vertex degrees are at most equal to d. Here, we can take B = (d, . . . , d, r, 1, . . . , 1), where 1 ≤ r < d and r ≡ n−1 mod d−1. The greedy tree G(B) is in this case called a Volkmann tree. Again, several extremality results now follow as direct applications of Corollary 4.2. For example, the Volkmann tree minimises the Wiener index [10] and the polynomial rf(T, x) for every x > 0 [20] (thus also the incidence energy), while it maximises the number of subtrees [23]. On the other hand, the M-tree M(B) is known to be extremal for the Hosoya index, the energy of a graph and the Merrifield-Simmons index [16,18]. We also obtain new results for the Steiner Wiener index (which is minimised by G(B)) and the solvability (which is minimised by M(B)). • Next, let A be the set of n-vertex trees with exactly ℓ leaves. Now we can take B = (ℓ, 2, . . . , 2, 1, . . . , 1) (n − ℓ − 1 copies of 2, ℓ copies of 1) and find that either G(B) or M(B) is extremal for each of the invariants we considered in the previous sections, thus recovering several known results (and adding some new ones). For instance, the greedy tree G(B) is known to minimise the Wiener index [9,34] and the polynomial rf(T, x) as well as the incidence energy [19]. On the other hand, it maximises the number of subtrees [3]. Similarly, the extremal tree for the Hosoya index, the Merrifield-Simmons index and the energy is known to be M(B) [36][37][38].
We find now also that G(B) minimises the Steiner Wiener index, while M(B) minimises the solvability. • Finally, let A be the set of n-vertex trees having r branching vertices, i.e., vertices of degree greater than or equal to 3. Here, we can take B = (n − 2r + 1, 3, . . . , 3, 1, . . . , 1) (r − 1 copies of 3, n − r copies of 1). It was shown in [26] that the greedy tree G(B) minimises the Wiener index in this class of trees if r ≤ n+2 3 , while the case r > n+2 3 was left as an open problem. Minimality of G(B) with respect to the Wiener index is a consequence of our results for arbitrary r now, and we also obtain extremality of G(B) or M(B) for all the other invariants mentioned in this paper.