Five results on maximizing topological indices in graphs

In this paper, we prove a collection of results on graphical indices. We determine the extremal graphs attaining the maximal generalized Wiener index (e.g. the hyper-Wiener index) among all graphs with given matching number or independence number. This generalizes some work of Dankelmann, as well as some work of Chung. We also show alternative proofs for two recents results on maximizing the Wiener index and external Wiener index by deriving it from earlier results. We end with proving two conjectures. We prove that the maximum for the difference of the Wiener index and the eccentricity is attained by the path if the order $n$ is at least $9$ and that the maximum weighted Szeged index of graphs of given order is attained by the balanced complete bipartite graphs.


Introduction
Let G be a simple connected graph, as we only work with connected graphs in this paper. We denote its vertex set by V (G) and its edge set by E(G). The independence number of a graph G, denoted by α(G), is the size of the largest independent vertex set. The matching number of a graph G is the size of a maximum independent edge subset of G, we will denote it by m(G) or m. We will denote by T(n, m) the set of all trees with n vertices and matching number m. A path P n is a path of order n.
Let d (u, v) denote the distance between vertices u and v in a graph G. The diameter d(G) of a graph equals max u,v∈V (G) d (u, v). The eccentricity of a vertex v, ε(v) equals max u∈V (G) d (u, v). The eccentricity of a graph G is the sum of the eccentricities over all vertices, i.e. ε(G) = v∈V ε(v).
The degree of the vertex u will be denoted deg (u). For an edge e = uv, n u (e) will be equal to the number of vertices x for which d(x, u) < d (x, v). The Wiener index of a graph G equals the sum of distances between all unordered pairs of vertices, i.e.
The mean distance of the graph G equals µ(G) = W(G) ( n 2 ) . Some general form of mean distance can be derived from the notion of power means.
Definition 1.1 The j th power mean of n positive real numbers x 1 , x 2 , . . . , x n is M j (x 1 , . . . , x n ) = j x j 1 + x j 2 + . . . + x j n n .
Other graphical indices used in this paper, are the hyper-Wiener index, the external Wiener index, terminal Wiener index, Szeged index and weighted Szeged index. They are defined respectively as n u (e) · n v (e) wSz(G) = e={u,v}∈E (G) (deg(u) + deg(v)) · n u (e) · n v (e) In Section 2 we give an alternative proof for a theorem of Dankelmann Dankelmann (1994) on the maximum Wiener index of a connected graph with given order and matching number. We prove this for a notion of generalized Wiener index W f , implying the result for e.g. the hyper-Wienerindex. Due to a relation between order, matching number and independence number, we also observe a power mean version of a result of Chung Chung (1988). We present alternative, short proofs for the main results of Dimitrov et al. (2019) and Jiang and Li (2019) based on results known before in Sections 3 and 4 respectively. Also we give a proof for Conjecture 4.3 in Darabi et al. (2021) in Section 5 and for Conjecture 1 in  in Section 6.
2 Maximum generalized Wiener index given m or α Theorems 2.14, 3.10 and 4.7 in the survey of Xu et al. (2014) give the extremal graphs attaining the minimum hyper-Wiener index among all graphs with given order and matching number, for the family of graphs being the connected graphs, the trees and the unicyclic graphs respectively. Some general version was proven in Chen et al. (2017) as the result holds for a more general class of indices represented by F. In this section we will prove the analog for the maximum. The general statement works for a different class of distance-based indices.

Definition 2.1 The generalized Wiener indices are of the form
where f is a convex function satisfying f (0) = 0 which is strictly increasing on R + .
Note that when we take f ≡ Id or f : x → x+1 2 , we get the Wiener index or the hyper-Wiener index, respectively. The condition that f (0) = 0 is just a handy convention, as W f is just shifted with n 2 c if one shifts f with a constant c. The additional constraint that f is convex (when comparing with the result in Chen et al. (2017)) is added to have the same extremal graph for the whole class of indices.
Let A n,m be a path with 2m − 1 vertices, with one leaf of the path connected to ⌈ n−2m+1 2 ⌉ different vertices and the other leaf with ⌊ n−2m+1 2 ⌋ pendent vertices, i.e. it is a balanced double broom with n − (2m − 1) leaves when n ≥ 2m + 1 and if n = 2m, it is a path.
For any generalized Wiener index W f , we will prove that A n,m is the unique extremal graph G attaining the maximum value of W f (G) among all graphs having order n and matching number m. This was known already for the Wiener index by Dankelmann Dankelmann (1994).
We will use a kind of tree rearrangements, which we call subtree pruning and regrafting (SPR). It was defined in Cambie (2019), but for completeness we give the definition here again.
Definition 2.2 (SPR) Let G be a graph. Given a rooted subtree S of G, such that the root d = S ∩ H. Pruning S from G is removing the whole structure S excluding the root d. Regrafting S at a vertex v, means that we are taking a copy S ′ of S which we insert at v, letting its root d ′ coincide with v. No additional edges are drawn in this process. We know that extremal graphs are trees, since deleting an edge which is not part of a maximum matching will increase the generalized Wiener index as at least one distance strictly increases. We will use the notation W f (T(n, m)) = max{W f (G) | G ∈ T(n, m)}. For m = 1, the extremal graphs are stars. So from now onwards, we assume m > 1, which implies that the diameter of the extremal graph (being a tree) is at least 3.
The first proposition we need for the proof is the following. Proposition 2.3 For fixed n, when m 1 < m 2 and the sets T(n, m 1 ) and T(n, m 2 ) are both nonempty, then W f (T(n, m 1 )) < W f (T(n, m 2 )).
Proof: Assume this proposition is not true. In that case there exist some n and m such that T(n, m) and T(n, m + 1) are both nonempty and W f (T(n, m)) ≥ W f (T(n, m + 1)). For some fixed n, we take the least integer m for which W f (T(n, m)) ≥ W f (T(n, m + 1)) holds and take an extremal graph G ∈ T(n, m) with W f (G) = W f (T(n, m)).
Since G is a tree which is not a path (as a path reaches the largest possible matching number), we can choose a leaf ℓ and a vertex w of degree at least 3 such that d(w, ℓ) is the smallest among all such choices. Considering G as a rooted tree in w, there are at least three branches, the path P from ℓ to w being one of them. Let S be a branch different from P and S ′ be the union of the remaining branches different from P and S. Here we do not consider w as a vertex of S nor of S ′ . We can prune the subtree S (with root w) and regraft it at ℓ. After this operation, the set of distances between P and S or S ′ is the same as before, while the distance between any vertex of S ′ and any vertex of S has increased with d(w, ℓ). Since f is a strictly increasing function, this implies that W f has strictly increased by performing the SPR operation, while the matching number has not increased with more than one. This implies that W f (G) = W f (T(n, m)) ≥ W f (T(n, i)) for every i ≤ m + 1 was not true. This contradiction implies that the proposition is true. ✷ Let G be an extremal graph and u 0 and u d be two vertices such that the distance between them equals the diameter and the path P between them equals u 0 u 1 . . . u d . If G is the path P, we are in a trivial case since P itself is of the form A n,m . In the other case, there are some subtrees attached to the path P. The following proposition gives more information about them.
Proposition 2.4 There are no vertices of P different from u 1 and u d−1 having degree at least 3.
Proof: If the proposition is not true, there is an extremal graph G with a subtree S connected to some u i with 1 < i < d − 1. Let G 1 and G 2 be the graphs by pruning and regrafting S at u 1 resp. u d−1 . Let H be the graph G\S, i.e. the graph G when S is pruned Note that every neighbour of a leaf will be in a maximum matching. In particular, without loss of generality, we can assume u 0 u 1 and u d−1 u d are edges in a maximum matching of H, G, G 1 or G 2 . This implies that the matching number of both G 1 and G 2 is exactly equal to m(H) + m(S), while the matching number of G, m(G), is at least equal to m(H) + m(S) (and plausible one larger). So the matching number of both G 1 and G 2 is not larger than the matching number of G. Let S 1 be the copy of S which is connected to u 1 and S 2 be the copy of S which is connected to u d−1 . We will prove that (1) Since f is convex and strictly increasing, . From this and the fact that it is strict for v = u i , Equation (1) follows. Hence at least one of the two graphs G 1 or G 2 has a larger generalized Wiener index than G and so taking into account Proposition 2.3 we conclude G was not extremal. ✷ Theorem 2.5 Let G be a graph of order n with matching number m. When f is a strictly increasing, convex function, then W f (G) ≤ W f (A n,m ) with equality if and only if G ∼ = A n,m .
Proof: As a consequence of Proposition 2.4, the extremal graph is a path u 1 u 2 u 3 . . . u d−1 with a pendent vertices to u 1 and b pendent vertices to u d−1 , where a, b ≥ 1. The maximum of the generalized Wiener index W f for such a graph with matching number equals m clearly needs a diameter being equal to 2m if n ≥ 2m + 1 and is the path if n = 2m. Since the maximum occurs when |a − b| ≤ 1 as we are considering the nontrivial case with d ≥ 3 (as m ≥ 2) and a + b = n − (2m − 1) being fixed. ✷ As an immediate corollary, we determine the extremal graphs attaining the maximum generalized Wiener index among all graphs having order n and independence number α for some regime.
Proof: Note that for any graph, the sum α + m ≤ n, since given an independent set I and a matching M , any edge of M contains at least one vertex which is not in I. This implies that m ≤ n − α ≤ n 2 . Applying Proposition 2.3 (recall extremal graphs with respect to m are trees) and Theorem 2.5, we have that W f (G) ≤ W f (A n,n−α ). Since the graph A n,n−α has independence number α, it is the unique extremal graph. ✷ In the case 2 ≤ α < n 2 , the proof of Dankelmann Dankelmann (1994) can be extended to W f , as well. In that case the extremal graph being the balanced dumbbell graph D n,α of diameter 2α − 1. This is the graph obtained when connecting two vertices from two cliques of almost equal order ⌈ n 2 ⌉ − α + 2 and ⌊ n 2 ⌋ − α + 2 by a path of length 2α − 3. Fig. 3: Extremal graph Dn,α Theorem 2.7 If G is a connected graph with independence number 2 ≤ α < n 2 , then W f (G) ≤ W f (D n,α ), with equality if and only if G = D n,α .
As corollaries, we get power mean versions of the result of Chung Chung (1988), which states that the average distance is bounded by the independence number.
Proof: The function f : x → x j is a convex function on R + when j ≥ 1. Note that for this f , we have . So from the previous two theorems, we know the maximum is attained when G equals A n,n−α or D n,α . Note that for every 1 ≤ i ≤ α− 1, there are more pairs of vertices {u, v} with d(u, v) = i then pairs with d(u, v) = 2α − i in the extremal graph. Combining with M j (1, 2α − 1) ≥ M j (i, 2α − i) (true by the inequality of Jensen), we conclude. ✷ By the observation that (2α − 1) j + 1 ≤ (2α) j when j ≥ 1, we also have the following corollary. Note that for j = 1, it is exactly the original result of Chung.

Maximum external Wiener index of graphs
In this section, we give a short alternative proof for the main result in Dimitrov et al. (2019), which proves Conjecture 11 in Gutman et al. (2016). We show that the conjecture is basically a corollary of a theorem in Gutman et al. (2009).
Remark that if T is a spanning tree of a graph G, Note that for any two vertices u and v in a tree, there are two leaves such that the path between them goes through u and v. This implies that adding an edge between two non-neighbours of any tree will strictly decrease the external Wiener index as at least one term got smaller (or even vanishes). As a consequence, any extremal graph is a tree.
Hence the result will follow from the following lemma, as we know the extremal graphs are trees.
Lemma 3.1 Let T be a tree of order n with ℓ leaves. Then Proof: Let U = {u ∈ V (G), deg(u) > 1} be the sets of nonleafs, which has size n − ℓ. Note that for every leaf v, G[U ∪ {v}] is a connected graph and hence Proof: Assume T is the extremal graph and it has ℓ leaves. Note that

Equality holds if and only if G[U ] is a path and
due to Lemma 3.1. Equality in the first part holds if and only if T is a double broom. A double broom for which equality holds in the second equality need to be balanced and balanced double brooms attain equality. The maximum among all graphs is now attained by the double brooms having ℓ leaves, where 2 ≤ ℓ ≤ n − 1 is an integer maximizing the expression. ✷

Maximum Wiener index of unicyclic graphs with given bipartition
In this section, we show that the answer to Problem 11.6 in Knor et al. (2016) is mainly a corollary of the proof of Problem 11.4 in the same survey, which was adressed in Cambie (2019). The problem, being the unsolved part in Du, was recently solved in Jiang and Li (2019) and . Nevertheless, one can observe that the proof by deducing it from earlier work is much shorter. We start with proving a lemma dealing with the case that the cycle is not minimal.
Lemma 4.1 Among all unicyclic graphs of order n ≥ 2k containing an even cycle C 2k , the Wiener index is maximized by the graph formed by attaching a path of order n − 2k to a vertex of a C 2k .
Proof: We can prove this by induction, the n = 2k case being the trivial base case as C 2k is the only unicyclic graph on 2k vertices containing a C 2k . Assume the lemma is true for n − 1 ≥ 2k. Any unicyclic graph G of order n > 2k containing a C 2k has at least one leaf v. Let H = G\v. Note that the distance from v to the C 2k is at most n − 2k and the diameter of G is at most n − k. At least k − 1 consecutive distances between v and vertices of C 2k appear twice, these are at most n − 2k + 1 up to n − k − 1. Thus i=n−2k+1 i and together with the induction hypothesis on H, we get the result. ✷ Using the notation as has been done in Cambie (2019) (Figure 9), the theorem is stated below.

Theorem 4.2 The maximum Wiener index among all n-vertex unicyclic graphs with bipartition sizes p, q
(1 < p ≤ q) is attained by exactly one graph, G 4 The maximum for the graphs in Lemma 4.1 is attained when k = 2. There are multiple ways to see this. Let G be C 2k with a path P n−2k attached to it. Let v be a neighbour of the vertex with degree 3, or a random vertex of G = C 2k if n = 2k. Then u,w∈G\v d(u, w) ≤ W (P n−1 ) and u∈G\v d(u, v) ≤ 2 · 1 + 2 · 2 + 3 + . . . + (n − 3).
Equality holds if and only if k = 2.
The graph G 4 1,1,2p−4 has a larger Wiener index than the extremal graphs in Lemma 4.1 for k ≥ 3, from which we conclude again. For this it is enough to note that for all k ≥ 3, we have as adding the path of order n − 2k to both structures only makes the difference larger. ✷

Maximum difference of Wiener Index and Eccentricity
In this section, we prove Conjecture 4.3 in Darabi et al. (2021).
Theorem 5.1 For n ≥ 9, among all graphs with order n, W (G) − ε(G) is maximized by P n . Moreover, P n is the unique extremal graph.
To start with, we prove that we can focus on trees as deleting an edge does not decrease the quantity Lemma 5.2 Let G be a graph with order n ≥ 9 and radius at least 3. Let e be an edge such that G\e is connected. Then (W − ε)(G) ≤ (W − ε)(G\e).
Proof: Let e = uv and assume (W − ε)(G) > (W − ε)(G\e). Suppose the shortest cycle in G containing e is C k . Note that distances do not decrease when deleting edges, so we have to focus on the eccentricities that increase. Let z be a vertex not belonging to C k for which the eccentricity increases when deleting e. Without loss of generality we can assume d(z, u) < d(z, v). Let ecc G\e (z) = d G\e (z, t) for a vertex t (where possible t = v). Then we know that d(z, t) < d G\e (z, t), so the shortest path from z to t in G uses the edge uv and so d(z, t) = d(z, v) + d (v, t). This also implies that d(v, t) = d G\e (v, e). Combining these observations with the definition of eccentricity and the triangle inequality, we get that As the difference in eccentricity for z is cancelled by the difference of distance between z and v, while z was taken arbitrary, which is only the case if k ∈ {3, 5} and then the difference is exactly equal to 1. Case: k = 3 To have a contradiction, both ecc(u) and ecc(v) need to increase when deleting e. This implies there is a vertex w such that 3 ≤ ecc(u) = d(w, u) < d G\e (w). Let v 2 be the neighbour of v on a shortest path in G from v to w. Then d G\e (v 2 , u) = d(v 2 , u) + 1. So if ecc G\e (v 2 ) = ecc(v 2 ), we have an additional difference that (in the expansion of W (G\e) − W (G)) is at least 1, leading to a contradiction. If ecc G\e (v 2 ) > ecc(v 2 ) ≥ 3, there is an other vertex x not belonging to the C 3 such that d G\e (x, v 2 ) > d(x, v 2 ) and we conclude again.
Case: k = 5 In this case, let v 2 be the neighbour from v in the C 5 different from u. When doing the check in the reduced case that (W − ε)(C k ) > (W − ε)(P k ), we take into account that the eccentricity of v 2 goes up by 1 in But since ecc(v 2 ) ≥ 3, there is a vertex x not belonging to the C 5 for which d G\e (v 2 , x) > d(v 2 , x). As we did not take this difference into account before when looking to Having proven this lemma, it is essentially enough to prove it for trees, once checking the result for graphs with radius at least 2. For this a bit of work is needed (as one can expect due to the behaviour of the extremal graphs for n ≤ 8).
Proof Proof of Theorem 5.1: First, one can check that W (G) − ε(G) is smaller than (W − ε)(P n ) when 15 ≥ n ≥ 9 in case G has radius at most 2. For n = 9, a brute force check confirms. For n = 10, if the diameter is at most 3, then W (G) ≤ 97 and ε(G) ≥ 10 and we are done. If the diameter is 4, we have W (G) ≤ 117 and ε(G) ≥ 2 · 4 + 2 · 3 + 6 · 2 = 26, so W (G) − ε(G) ≤ 91 < 95 = (W − ε)(P 10 ). The cases 11 ≤ n ≤ 15 work similarly. For n ≥ 16, note that the diameter of G is bounded by 4 and so W (G) ≤ 4 n 2 < (W − ε)(P n ). So from now on, we only have to consider graphs with radius at least 3 and hence by Lemma 5.2 we can first focus on trees. A bruteforce check by computer over all trees of order 9 ≤ n ≤ 20 verifies the theorem for these values. For n ≥ 21, we first observe that the diameter of an extremal graph is at least 7, since otherwise (W − ε)(G) ≤ 6 n 2 − 3n < (W − ε)(P n ). Now we can prove the statement by induction. If the diameter d equals n − 1, we have the path P n . If the diameter is smaller, d ≤ n − 2, one can remove a leaf v which is not part of the diameter. Now the eccentricities of all vertices different from v are the same in G and G\v. By the induction hypothesis, we have (W − ε)(G\v) ≤ (W − ε)(P n−1 ). Furthermore we have from which we conclude. This implies that P n is the unique tree maximizing (W − ε)(G). By Lemma 5.2 no graph with a spanning tree which is not a path can be extremal (note that the radius does not decrease when removing edges). Since the cycle C n (and the path P n itself) is the only graph which has only P n a spanning graph, but (W − ε)(C n ) < (W − ε)(P n ) for n > 5, as concluded from the computation in Equation 2, the path P n is the unique extremal graph. ✷ Additionally, we add two remarks on the work in Darabi et al. (2021) about the minimum for W − ε. In their Theorem 3.2, the authors prove that the minimum for (W − ε)(T ) among trees is attained by caterpillars. More precisely, the extremal tree is P n when n ≤ 6 and if n ≥ 7, the extremal tree is attained for the star S n−1 with one edge subdivided. This is mainly a corollary of the following lemma, as it implies that we only have to compare a few possible trees. with equality if and only if they are all connected to the same vertex on the diameter. We note that for every u ∈ U , 0≤i≤d d(u, v i ) − ε(v) is minimal if u is connected to a central vertex and equality is also possible if it is connected to a neighbouring vertex of a central vertex when d + 1 is odd as then there is only one central vertex. Here we use that We now also determine this minimum among all graphs.
Proposition 5.4 For every graph G of order n, we have (W − ε)(G) ≥ n(n−4)
Proof: For every vertex v, one has u∈V \v d(u, v) − 2ε(v) ≥ n − 4, since all distances are at least equal to one, there is a vertex u with d(u, v) = ε(v) and an other one with d(w, v) ≥ ε(v) − 1. Summing over all vertices v, we conclude that 2(W − ε)(G) ≥ n(n − 4). Dividing by 2 and observing that (W − ε)(G) is always an integer, we conclude. ✷ The minimum of (W − ε)(G) is attained by the complement of n 2 K 2 if n is even, n−1 2 K 2 ∪ K 1 or n−3 2 K 2 ∪ P 3 if n is odd.
For n ≥ 6, this is the exact characterization of the extremal graphs. The graph P 4 for n = 4 and the one sketched in Figure 4 for n = 5 are also extremal.  First, we make the following crucial observation.
Proof: Since n u (e) + n v (e) ≤ n, this is trivial when deg(u) + deg(v) ≤ n. If deg(u) + deg(v) > n, then u and v have at least deg(u) + deg(v) − n neighbours x in common, which satisfy d(x, u) = d(x, v) and hence do not belong to N u (e) nor N v (e). Hence n u (e) + n v (e) ≤ n − (deg(u) + deg(v) − n) which is equivalent with n u (e) + n v (e) + deg(u) + deg(v) ≤ 2n. ✷ Let the degrees of the vertices of the graph be a 1 , a 2 , . . . , a n . For an edge e = uv whose end vertices have degree a i and a j , let x e = ai+aj 2 be the average degree of the two endvertices. Then by double counting, we find the following two equalities (the first one being the hand shaking lemma) Next, we prove two propositions which are the main ingredients for the proof.
Now we have x e (n − x e ) ≤ n 2 4 if n is even or when n is odd and x e = n 2 (as 2x e is integral). When x e = n 2 , then Lemma 6.2 gives n u (e) + n v (e) ≤ n and hence n u (e) · n v (e) ≤ ⌊ n 2 4 ⌋ and the conclusion holds again. ✷ Proposition 6.5 For any graph G, we have e 2 (n − x e ) ≤ n n 2 4 .
Proof: Using Lemma 6.3, we get