1 Introduction
The sum of distances between all pairs of vertices in a connected graph was first introduced by Wiener [16] in 1947. He observed a correlation between boiling points of paraffins and this invariant, which has later become known as the Wiener index of a graph. Today, Wiener index is one of the most used descriptors in chemical graph theory.
Wiener index was used by chemists decades before it attracted attention of mathematicians. In fact, it was studied long before the branch of discrete mathematics, which is now known as Graph Theory, was developed. Many years after its introduction, the same quantity has been studied and referred to by mathematicians as the gross status [9], the distance of graphs [5] and the transmission [15]. A great deal of knowledge on the Wiener index is accumulated in several survey papers, see e.g. [3, 10, 12, 17].
In what follows, we formally define this index. Let denote the distance between vertices and in . The transmission of a vertex is the sum of distances from to other vertices of , i.e., . Then the Wiener index of equals
Due to big importance and popularity, there are many results about graphs with extremal (either maximum or minimum) values of Wiener index in particular classes, see the surveys mentioned above. However, only few papers are devoted to the second, third, etc extremal graphs, although it is important to understand the ordering of graphs by Wiener index. One of the reasons is that results of this type are much more complicated, often including the extremal graph as a trivial case. Of course, the situation is known for trees. In [4] there are described the first 15 trees with the smallest value of Wiener index. Analogously, in [2, 13] there are the first 15 trees with the greatest value of Wiener index. Graphs with the second minimum and second maximum value of Wiener index over the class of unicyclic graphs are found in [6]. In this paper we describe graphs with the second and third maximum value of Wiener index over the class of 2vertex connected graphs.
We use the following notation. As usual, is the cycle on vertices. Let be a graph on vertices comprised of three internally disjoint paths with the same endvertices, where the first one has length , the second one has length , and the last one has length . Notice that has vertices. Also observe that is the cycle on vertices plus an edge linking two vertices at distance two on the cycle. When using the notation we assume that and . Our main result is the following theorem.
Theorem 1.
Let and let be a 2vertex connected graph on vertices different from , and . Then
2 Proof of the result
We start with some definitions. For two vectors
and of the same finite dimension, we write if for every coordinate we have . Moreover we define as the value . It is clear that implies .Let be a connected graph on vertices and let be a vertex of . The distance vector of is the dimensional vector given by . Observe that .
If is even, the vector has dimension and contains the value 2 in each coordinate except for the last one which is 1. If
is odd,
has dimension and each of its coordinates has value 2. For example and .Let be a 2vertex connected graph and let be a vertex of . Since has no cutvertices, every coordinate of has value at least 2, except for the last one which can be 1. In other words, for every vertex of a 2vertex connected graph we have . This implies the following classical result.
Theorem 2.
For every , the cycle is the unique graph which has the maximum Wiener index over the class of 2vertex connected graphs on vertices. Moreover, .
Now we describe the structure of graphs with the second and third maximum Wiener index over the class of vertex connected graphs on vertices. First we need some definitions and lemmas.
We denote by the first coordinate of such that . If such a coordinate does not exist, we set . Notice that if , then . For a graph on vertices we denote by the sequence formed by the values of all given in nondecreasing order. For instance, the sequence is given by for every and . In other words we have with twice the value at the end if is even and three times if is odd. Similarly for , the sequence is given by , and for every . In other words we have with once the value if is odd and twice if it is even.
As previously precised, we write if for every we have . Moreover, if for some , then we write .
The next two lemmas give necessary conditions to bound the Wiener index of a graph by the ones of and .
Lemma 3.
Let be a 2vertex connected graph on vertices. If , then . Similarly if , then .
Proof.
Let be one of the graphs or , and let with . The vector has 3 at coordinate and 2 everywhere else, except possibly for the last coordinate. Therefore, has the largest value among
(1) 
where is a 2vertex connected graph of order . The same conclusion also holds if as in this case .
Now assume that . Relabel the vertices of (resp. ) so that (resp. ) and (resp. ) for . By assumption, for every we have , and there exists such that . Further, for every we have , by (1). Since we also have , we obtain and consequently . ∎
In particular, since for we have , we obtain .
For a graph and , we say that is bad if has at least two elements with value greater than 2. For every bad vertex in , let be the coordinate of the second element which is at least 3 in . For all bad vertices of we sum the values , and we denote by the result.
Lemma 4.
Let be either or . Let be a 2vertexconnected graph on vertices such that . Then .
Proof.
Let and let be a vertex in with . The vertex has at coordinate and everywhere else, except for the last coordinate that may be . Such a vertex satisfies . Moreover, as noticed in the proof of Lemma 3, for every in with we have , see (1).
Similarly, for all , among the bad vertices with and , the highest possible value is obtained when has at coordinates and , and at each other coordinate (except possibly the last one). Thus, for every bad vertex with and , we have . So we have
and
Hence, the lemma easily follows. ∎
In the next two propositions we consider two particular subclasses of the 2vertex connected graphs. For , let be the class of graphs comprised of for . We have the following claim.
Proposition 5.
Let or , and let be a graph of . Then
For and , the values of for are summarised in the table below.
4  5  6  7  

7  14 14  24 25 23  39 38 38 
8  10  

58 58 55 56  115 113 107 109 112 
Table 1: Values of for and .
Proof.
Assume that . As noticed below Lemma 3, we have . Let us now focus on for . Let and be the two vertices of degree 3 in , and let be the internal vertices of the path of length from to . Further, let be the internal vertices of the path of length from to . We have . For we have and for we have . Finally, if is odd then we have and if is even then we have . Similarly if is odd then we have and if is even then we have . Therefore the numbers in are at least twice each integer from to , plus at most three times if is odd and at most four times if is even. Therefore we have if is odd and if is even.
Recall that , with once the value if is odd and twice if is even. Therefore if is odd, then ; and if is even, then .
Now notice that since and , and are bad vertices with . For instance, has three distinct vertices at distance two, which are , and . Moreover, since , and are bad vertices with . For instance, if then and , , and are distinct vertices at distance from , and if , then , , and are distinct vertices at distance from . Moreover, if we can find another bad vertex. Indeed, if , then and , and are distinct vertices at distance 3 from , which is bad then. If , then and , and are at distance 4 from , which is bad. And if , then and , and are at distance 4 from which is bad. Therefore , with a strict inequality if . If then and . If then and . If , then and . In all cases we have , by Lemma 4. ∎
For , let be the class of graphs built from by adding two distinct edges, each linking two vertices at distance precisely 2 along . That is, a graph belongs to if and , where . Further, by we denote a graph from when . So consists of two disjoint triangles connected by two independent edges. We have the following claim.
Proposition 6.
Let . Every graph of satisfies the inequality , with the unique exception of for which .
Proof.
Let . If then is a strict supergraph of , which implies .
So assume that . We compare with . Notice that both and are cycles of length with two additional vertices. Let us call these two additional vertices by and in , and by and in . Then
Since is connected, we have , and in , and are at distance . Further, is a cycle of length with an additional vertex adjacent to two neighbours in the cycle, and is a cycle of length with an additional vertex adjacent to one vertex in the cycle. Therefore , and by symmetry, . Therefore, . Now combining this inequality with Proposition 5 we obtain that for all , with a unique exception when and . In this case we must have , and consequently . ∎
Consider with vertices and edges . Let be obtained from by adding the edge , and let be obtained from by adding the edge . Denote . Moreover, let be obtained from by adding the edge . Observe that when , and . The following theorem implies and precises Theorem 1.
Theorem 7.
For , there are three vertex connected graphs and they satisfy . For every , let be a 2vertex connected graph on vertices different from , , and . Moreover, assume if and if . We have :

for ,

for ,

for ,

for ,

for , and

and for and .
Proof.
For , let be the class of vertex connected graphs on vertices different from , , and . Let be a graph with the maximum Wiener index over . We want to prove except when or . Notice that no proper subgraph of is in , since otherwise this proper subgraph would have a bigger Wiener index than . First suppose that has a Hamiltonian cycle . We distinguish three cases.
Case 1: contains an edge where and are at distance at least 4 along . Then itself is a graph from . Thus, by the choice of we have and for some . By Proposition 5, .
Case 2: contains an edge where and are at distance 3 along . Since the Hamiltonian cycle with is , must contain one more edge, say . Since with is in , there are no other edges in . By Case 1 we may assume that and are at distance 2 or 3 along . Since is a supergraph of , we have if , by Proposition 5. The cases when were checked by a computer and it was found that with two exceptions if , namely when and , and with one exception if , namely when .
Case 3: The edges of not belonging to link vertices at distance 2 along . Let us denote by these edges. Since itself is a graph from , we have . Now Proposition 6 concludes the proof.
So assume that has no Hamiltonian cycle. Let be a vertex of with the maximum value of , that is . We denote this value by . If , it is clear that and Lemma 3 implies the result. So assume that . We know that there are exactly two vertices at distance from for every . Denote these vertices by and . Notice that for the only neighbours of and are contained in (with ). Moreover, since is 2vertex connected, there exists a matching of size 2 between and for . So we assume that and are edges of for and thus that is a path of . Finally, denote by the set . Let be the subgraph of obtained by removing the edges of which do not belong to . Notice first that is a 2vertex connected graph. Indeed, since is connected (otherwise or would be a cutvertex of ), no vertex of is a cutvertex of . Moreover, no vertex of is a cutvertex of otherwise it would be a cutvertex of . Furthermore, is not a cycle or or , otherwise would have a Hamiltonian cycle. We may also assume that is not , since otherwise is a supergraph of and . Hence, belongs to , and by the choice of we have . We consider two cases.
Case 1: . In this case or . If , denote by the unique vertex of . Since is 2vertex connected, and are edges of and has a Hamiltonian cycle, contradicting a previous assumption. If , denote by and the vertices of . Analogously as above, since is 2vertex connected, we can assume that and are edges of . Since has no Hamiltonian cycle, is not an edge of . But is 2vertex connected, and so and are edges of . Hence .
Case 2: . Below we will show that admits a nondecreasing subsequence with , and the existence of a coordonate for which . Then we will conclude that . Indeed, for every value with there will exist at least elements before it in , which means that , and hence . If , then we have . Further, has at least two vertices of degree at least 3, for otherwise would not be 2vertex connected. Hence, if , then we have and . Moreover, as we have . By Lemma 3, we conclude that .
Thus, all that remains to show is the existence of subsequence of with , and the existence of a coordonate for which . Since we have , and we may assume that has at least two neighbours in . We find a special path in . There are two cases to consider. First, if has at least two neighbours in , then for every . In this case we set , and . So is an induced path, the only neighbours of in are those of and and is a subsequence of achieved only by vertices of . If has only one neighbour in , then has degree 2, and we denote by its neighbour different from . The degree of is at least 3, for otherwise we would have , which contradicts the fact that has the maximum value in . So we have and for . In this case we set , and . If is not an induced path in , then is an edge of . But since is not a cutvertex of , is 2vertex connected. Since has no Hamiltonian cycle, is different from , and . And analogously as before Case 1 we may assume that is different from . So which is not possible. Thus here again, is an induced path in , the only neighbours of in are those of and and