Abstract

The Harary index of is the sum of reciprocals of distance between any two vertices in . In this paper, we obtain the graphs with the maximum and second-maximum Harary indices among -vertex unicyclic graphs with diameter .

1. Introduction

In this paper, all graphs are simple, undirected, and connected. Denote by , the edge set and vertex set of and , the number of edges and vertices in , respectively. When , the graph is called a unicyclic graph. Let (or , be the degree and the neighborhood of a vertex in , respectively. When , we call is a pendant vertex. The distance between and    is denoted by The diameter of is . The graph (or ) arisen by deleting the edge (or by adding a new edge ). Let and be the path and cycle with , respectively. Denote by a path of , where (if ). When , , is an internal path of . When , is a pendant path of . If , specially, is a pendant edge. When the subgraph is itself, where is induced by in , is an induced path. For other terminologies and notations, we refer the readers to [1].

The Harary index , has been introduced independently in [2, 3]. Its calculation is as follows: where is defined as above and the sum goes over all the pairs of vertices in .

The set of -vertex unicyclic graphs with diameter is denoted by The graph (see Figure 1) on vertices arisen from by attaching pendant edges to and adding a new vertex to be adjacent to and

The graph (see Figure 1) arisen from by attaching pendant edges to and adding a new vertex to be adjacent to and The -vertex graph arisen from by attaching pendant edges to and adding two new adjacent vertices and to be adjacent to , denoted by (see Figure 2). So, if , the graph arisen from by attaching pendant edges to one vertex of .

Note that -vertex graph arisen from by attaching pendant edges to and one pendant edge to and adding a new vertex to be adjacent to and . arisen from by attaching pendant edges to and adding a new vertex to be adjacent to and

Let , be the graph with vertices arisen from by adding a new vertex to be adjacent to one vertex . arisen from by attaching pendant vertices to and identifying with one vertex of , denote . Let be a -vertex unicyclic graph arisen from by adding a new vertex to be adjacent to and (see Figure 2), arisen from by attaching pendant vertices to , and denote .

Lately, the investigations on the spectral radius or eigenvalue or topological index of a special class of graphs and the topological properties of a certain class of networks remain a popular topic to researchers. For example, J.Q. Fei and J.H. Tu [4] characterized the complete characterization of the degree Kirchhoff index of bicyclic graphs. J.B. Liu et al. [5] discussed the topological properties of certain neural networks. B. Ning and B. Li [6] discussed the spectral radius of connected claw-free graphs. Y.Y. Wu and Y.J. Chen [7] analyzed the eccentric connectivity index of graphs. C. Wang et al. [8] obtained the least eigenvalue of the graphs whose complements are connected and have pendant paths. Many results can be seen in [216] and other papers. In particular, A. Ilic et al. [13] discussed the Harary index among the trees with fixed diameter. In this paper, we determine the graphs which have the maximum and second-maximum Harary indices among all the -vertex unicyclic graphs with diameter .

2. Lemmas

Lemma 1 (see [14]). Let , , and be three connected, pairwise disjoint graphs; note that , , . The graph is obtained by identifying the vertices , and , between , , , respectively. is obtained by identifying the vertices , , from , , and is obtained by identifying the vertices , , from , , ; then we can get

Lemma 2 (see [9]). Let be an -vertex unicyclic graph and be the graph defined as above. Thenif and only if , and the equality holds. When , then , and when , , then .

Lemma 3. Let be the graph defined as above; then if and only if , the equality holds.

Proof. By the calculation of Harary index, we can get the following.
(1) If , (2) If , When is odd, we can get .
Thus the result holds.

Lemma 4. Let and and be the set and two graphs defined as above, respectively. ; thenif and only if , the equality holds.

Proof. Choose a graph , such that is the maximum. The following claims play a crucial role.
Claim 1. .
Proof. First, we prove . Otherwise, ; denote , ; letusing Lemma 1, we get , a contraction.
So, , let , ,
(1) If , let if , let (2) If or , let (3) If , let i.e., ;
if , let i.e., .
From Lemma 3 and the calculation of , we can calculate that , a contraction.
Claim 2. .
Proof. Otherwise, if , let ; if , let . From Lemma 3, we can get , a contraction.
By Claims 1-2, we have the graph or .
Claim 3. .
Proof. If is even, we haveIf is odd, , .
By Claims 1-3, we have .
Thus the result follows.

3. Main Results

In this section, we will list our main results.

Theorem 5. Let and be defined in Section 1, the n-vertex graph ; then if and only if , the equality holds.

Proof. Let ; using Lemma 2, the result holds for . If , then . So, we discuss that .
Choose a graph with being the maximum. Note that is the only cycle and is the induced path in ; assume that ; we consider the following claims.
Claim 1. .
Proof. Otherwise, suppose that there exists a path connecting the cycle and the path with ; denote and . Let Then, applying Lemma 1, , a contraction.
Using Claim 1, we note that , .
Claim 2. For any , .
Proof. Otherwise, assume that there exists a vertex with , , . Suppose that , . Let Then, using Lemma 1, , a contraction.
By Claim 2, we have any vertex is pendant vertex.
Claim 3. .
Proof. Otherwise, suppose that , .
(1) If , denote , (if exists), . Let (2) If , denote , (if exists), . Let Then, applying Lemma 3 and the calculation of , , a contraction.
Claim 4. (1) , ; (2) , .
Proof. (1) Otherwise, we assume that . The graph arisen by deleting all edges in of and incidence with except the edges of , adding the edge , connecting all isolated vertices to the vertex (if ) or to the vertex (if ) of . Together with the definition of the Harary index and Lemma 3, , a contraction.
(2) Otherwise, we assume that . The graph is obtained from by deleting all edges in and incidence with except the edges , adding the edge , connecting all isolated vertices to the vertex . We can calculate that , a contraction.
By Claim 4 and Lemmas 1 and 3, we get . If , applying Lemma 3, (see Figure 2); if , applying Lemma 4, .
Claim 5. .
Proof. If is even, we haveIf is odd, we haveBy Claims 1-5, we have .
Thus the result follows.

Theorem 6. Let be defined in Section 1; the graph ; then
(1) If is even, we obtain if and only if , the equality holds. if and only if , the equality holds.
(2) If is odd, we have if and only if , the equality holds.

Proof. Choose a graph , such that is as large as possible; together with Lemmas 1, 3, and 4 and Theorem 5, we have the following.
(1) If is even, or or .
In fact,(1.1) When ,
(1.2) When ,
(2) If is odd, , so or or .Thus the result follows.

Data Availability

The data used to support the findings of this study are included within the article.

Conflicts of Interest

The authors declare that they have no conflicts of interest.

Acknowledgments

This paper is supported by the Natural Science Foundation of China (11871077), the National Natural Science Foundation of China (11371028), the Natural Science Foundation of Anhui Province of Anhui (1808085MA04).