Next Article in Journal
Bidirectional Conservative–Dissipative Transitions in a Five-Dimensional Fractional Chaotic System
Next Article in Special Issue
Modular H-Irregularity Strength of Graphs
Previous Article in Journal
Spatiotemporal Dynamics of a Predator–Prey Model with Harvest and Disease in Prey
 
 
Font Type:
Arial Georgia Verdana
Font Size:
Aa Aa Aa
Line Spacing:
Column Width:
Background:
Article

Extremal Values of Second Zagreb Index of Unicyclic Graphs Having Maximum Cycle Length: Two New Algorithms

Department of Mathematics, Faculty of Arts and Science, Bursa Uludag University, Gorukle Campus, 16059 Bursa, Turkey
Mathematics 2025, 13(15), 2475; https://doi.org/10.3390/math13152475
Submission received: 12 June 2025 / Revised: 28 July 2025 / Accepted: 29 July 2025 / Published: 31 July 2025
(This article belongs to the Special Issue Graph Theory and Applications, 3rd Edition)

Abstract

It is well-known that the necessary and sufficient condition for a connected graph to be unicyclic is that its omega invariant, a recently introduced graph invariant useful in combinatorial and topological calculations, is zero. This condition could be stated as the condition that the order and the size of the graph are equal. Using a recent result saying that the length of the unique cycle could be any integer between 1 and na1 where a1 is the number of pendant vertices in the graph, two explicit labeling algorithms are provided that attain these extremal values of the first and second Zagreb indices by means of an application of the well-known rearrangement inequality. When the cycle has the maximum length, we obtain the situation where all the pendant vertices are adjacent to the support vertices, the neighbors of the pendant vertices, which are placed only on the unique cycle. This makes it easy to calculate the second Zagreb index, as the contribution of the pendant edges to such indices is fixed, implying that we can only calculate these indices for the edges on the cycle.

1. Introduction

Throughout this paper, we let G = ( V , E ) be a graph with the vertex set V ( G ) = { v 1 , v 2 , , v n } and edge set E ( G ) . Let | V ( G ) | = n and | E ( G ) | = m be the order and the size of G. In that case, we use G ( n , m ) in place of G to emphasize the order and size of G. By a simple graph, we mean that the graph has no loops or multiple edges. If v i and v j are adjacent vertices of G and if the edge e connects them, this situation will be denoted by e = v i v j . In such a case, the vertices v i and v j are called adjacent vertices and the edge e is said to be incident with v i and v j . For any vertex v V ( G ) , we denote the degree of v by d G ( v ) or d ( v ) . The smallest and biggest vertex degrees in a graph will be denoted by δ and Δ , respectively. If the degree of a vertex is 1, then this vertex is called a pendant vertex, and the edge incident to it is called a pendant edge. If the end vertices of an edge have degrees a and b, then this edge is said to be of type { a , b } . If there is at least one path between every pair of vertices of a graph, then the graph is said to be connected. Also, the set of all adjacent vertices of a vertex v in a graph G is called the neighborhood of v in G and is denoted by N G ( v ) .
Topological indices, also called molecular descriptors by chemists, are the mathematical formulae giving us an invariant number as a result for all isomorphic graphs. The first such index is known as the Wiener index, defined by Wiener in 1947, to compare the boiling points of some alkane isomers. Since then, over 3000 such indices have taken their place in chemical databases for several applications. In this paper, we shall consider one of these indices, called the second Zagreb index, and calculate its extremal values for all connected unicyclic realizations of a given degree sequence such that the cycle length of the unique cycle in these realizations is maximum. We use the recently introduced graph invariant called omega invariant to determine unicyclicness condition obtained in [1] and the maximum cycle length formula obtained in [2] to obtain our results.
Of course, if the graphs are given, then the calculation of Zagreb or any other indices of graphs is very easy. But there is no general way of finding the values of any index for all the realizations of a given degree sequence. So here, not being able to calculate the second Zagreb index, we algorithmically find the extremal values of this index for unicyclic graphs with maximum cycle length. In the future, we believe that there will be follow-up papers for other graph classes and for other index types.
The first and second Zagreb indices of a graph G were defined by Gutman and Trinajstic in 1972 [3] by
M 1 ( G ) = e = u v E ( G ) ( d u + d v ) and M 2 ( G ) = e = u v E ( G ) d u d v ,
respectively. The first Zagreb index is also formulated by M 1 ( G ) = v V ( G ) d v 2 , alternatively. Some properties of these two indices are studied in [4,5,6,7,8,9,10].
The extremal values of topological indices are quite useful when we cannot obtain the exact values of them.
A recently defined graph invariant is called the omega invariant, see [2], which is defined for a degree sequence D = { 1 ( a 1 ) , 2 ( a 2 ) , , Δ ( a Δ ) } by Ω ( D ) = i = 1 Δ a i ( i 2 ) where a i ’s are non-negative integers and Δ denotes the biggest vertex degree. Although it has a close relation with these two earlier graph parameters mentioned in [1,2,11], the omega invariant is still used in classifying several graph theoretical, topological and combinatorial properties, giving shorter proofs of the existing theorems such as Edmonds’ theorem which was proved in 1964 on the potential connectivity of realizations of a degree sequence and also in answering several open problems such as the connectivity of the realizations of a given degree sequence which was still an open problem before omega invariant was defined. The answer to this important open problem was given by the following statement: If Ω ( D ) 4 , then all the realizations are disconnected and cannot be drawn as a connected graph in any way. For all other values of Ω ( D ) , the realizations could be connected or disconnected, which is briefly stated with the statement “potential connected”. Another example of open problems answered by the omega invariant is the cyclicness of the realizations of a degree sequence. In [1], the conditions for the cyclicness, in particular, acyclicness, unicyclicness, bicyclicness, tricyclicness, etc., are all stated in terms of omega invariant. There are over 60 papers, hundreds of conference papers, and at least five PhD theses on the omega invariant in the literature so far, and many graph parameters are related to the omega invariant, making it an invaluable tool for many calculations. In the remaining parts of this manuscript, we shall make use of some fundamental properties of the omega invariant, in particular, with the unicyclic realizations of D which are characterized by the statement that Ω ( D ) = 0 . We could just use the word “unicyclic” for the realizations instead of using Ω ( D ) = 0 , but as we leave some open problems for acyclic, bicyclic, tricyclic, etc., of the realizations as a generalization of the problem studied in this manuscript, we have to use omega invariant necessarily for this generalization possibility.
In many problems with graph parameters or topological graph indices, one cannot obtain the exact values of the required parameter or index. In such cases, we may go for the maximum and minimum values instead of the exact value. Similarly, we may be considering some property for a family of graphs that share a common property. Such problems are called extremal problems. A reasonable problem to consider would be the following:
Problem 1.
Find the extremal values of M 1 and M 2 for all connected unicyclic realizations of a given degree sequence D having maximum cycle length n a 1 .
Here, we answer this problem that we propose, and many similar results can be obtained for thousands of other graph indices. The methods that will be utilized could show slight changes from the ones here, according to the differences between topological graph indices.
One may wonder why we are dealing with the case of maximum cycle length. If we do not put this condition and the length of our unique cycle is shorter than n a 1 , say of length k, then n a 1 k vertices have to be placed outside the unique cycle. The only places are the ends of pendant edges. So the situation becomes more complicated and needs further assumptions. Without new assumptions, there is a large number of possible realizations, making the situation difficult to handle.
As the first Zagreb index can be reformulated as the sum of squares of all vertex degrees, for a given degree sequence D, all values of M 1 ( G ) where G is a realization of D will be the same. Therefore, the answer to our problem is quite obvious for the first Zagreb index:
Proposition 1.
M 1 ( G ) is fixed for all connected realizations G of a unicyclic degree sequence D having maximum cycle length n a 1 .
Hence, the minimum and maximum values of M 1 for this class of graphs are equal to each other. Therefore, we can only study the extremal values of the second Zagreb index for the same class of graph realizations.

2. Minimum Values of Second Zagreb Index of Unicyclic Graphs Having Maximum Cycle Length

Let Ω ( D ) = 0 . In [2], it was shown that all connected realizations of D must be unicyclic and also the maximum cycle length can be a 2 + a 3 + a 4 + + a Δ = n a 1 in Theorem 3.3 in [2]. Let G i ( k ) be a unicyclic graph with cycle length k. By [2], k = 1 , 2 , , n a 1 . As we are dealing with unicyclic graphs, which have the maximum cycle length, we shall take k = n a 1 . We want to determine the smallest second Zagreb index of all G i ( n a 1 ) . In the case of maximum cycle length, all non-pendant vertices must be on the unique cycle. Also note that the placement of these vertices on the cycle does not affect the value of the second Zagreb index. We now have a useful result which will be needed later:
Observation 1.
Let d i 3 . The contribution d i of a pendant edge { 1 , d i } to the second Zagreb index is the same for all realizations G i ( n a 1 ) .
Therefore, we may omit the contributions of pendant edges when comparing the second Zagreb indices of all unicyclic realizations having the maximum value of the M 2 . Henceforth, we shall denote the part of M 2 ( G i ( n a 1 ) ) which is calculated only by means of non-pendant edges by M 2 * ( G i ( n a 1 ) ) . Of course, this argument is only valid for connected unicyclic graphs.
In the following result, we calculate the total contribution of all pendant edges to the second Zagreb index by subtracting the contribution of non-pendant edges from the contribution of all edges:
Lemma 1.
Let G be a realization of a unicyclic degree sequence D with maximum cycle length. Then, the total contribution of all pendant edges to the second Zagreb index is
M 2 ( G ) M 2 * ( G ) = i = 3 Δ a i i 2 2 i .
Proof .
We know that the graph is unicyclic by [2]. The total contribution of all pendant edges to the second Zagreb index is M 2 ( G ) M 2 * ( G ) . Recall that there are n a 1 non-pendant vertices which are placed on the unique cycle of the graph G. If these vertices have degrees i 2 , then there are i 2 pendant edges at each such vertex, as such a vertex is connected to two other neighboring vertices of the cycle, and as the graph is unicyclic. The contribution of each pendant edge, which will have vertex degrees 1 and i is i · 1 = i and for each vertex, each of the i 2 pendant edges will contribute this much. Finally, there are a i times non-pendant vertices of degree i. For the vertices of degree 2 on the cycle, i 2 = 0 so no contribution is obtained from these vertices. So the sum is taken over all vertices of degree at least 3, and the required contribution is
M 2 ( G ) M 2 * ( G ) = i = 3 Δ ( i 2 ) ( i · 1 ) a i = i = 3 Δ a i i 2 2 i .
We now give a useful result which will help us to prove our algorithm:
Lemma 2
((Rearrangement inequality) [12]). Let r 1 r 2 r n and s 1 s 2 s n be two sequences of integers. For any permutation ( t 1 , t 2 , , t n ) of ( r 1 , r 2 , , r n ) , we have
r 1 s 1 + r 2 s 2 + + r n s n s 1 t 1 + s 2 t 2 + + s n t n r n s 1 r n 1 s 2 + + r 1 s n .
Note that the smallest value of the sum of the products of r i ’s and s i ’s appears when the larger values are multiplied by smaller values. This fact will be the key point in our algorithm.
Let D = { 1 ( a 1 ) , 2 ( a 2 ) , , Δ ( a Δ ) } be a realizable degree sequence with Ω ( D ) = 0 . Here a i 0 are integers and Δ is the biggest vertex degree. We relabel the vertex degrees that are greater than 1 by d 1 d 2 d n a 1 . The following algorithm gives us the realization of D with the minimum second Zagreb index.
Theorem 1 (Minimum second Zagreb index algorithm).
Consider a realization G = G i ( n a 1 ) of a unicyclic degree sequence D that has a maximum cycle length constructed as below. Then G has the minimum second Zagreb index amongst all unicyclic realizations of D having maximum cycle length.
  • Label the vertices on the cycle by v 1 , v 2 , , v n a 1 in rotating order (clockwise or anticlockwise). Wlog, we choose anticlockwise orientation. Assign the largest vertex degree d 1 to v 1 .
  • Assign the smallest vertex degree d n a 1 to v 2 and the next smallest vertex degree d n a 1 1 to v n a 1 . That is, to both neighbors of the vertex with the largest vertex degree, we must place the two smallest vertex degrees.
  • Assign the next largest vertex degree d 2 to v 3 and the remaining next biggest vertex degree d 3 to v n a 1 1 .
  • Repeat the last two steps until all vertices are labeled by the remaining vertex degrees. Note that when n a 1 is odd, we have to label the last remaining vertex with that final degree, creating no new edge products.
Proof .
Our aim is to place n a 1 positive integers to n a 1 vertices on a cycle such that M 2 * (and hence M 2 ) takes its minimum value. By the rearrangement inequality in Lemma 2, we must place two smallest degrees next to a large degree. So we start with the biggest degree d 1 and place the smallest two degrees to its adjacent vertices. At the next step, we must label the two adjacent vertices by the two largest degrees. The steps continue by placing the two largest and the two smallest degrees in a row, finishing the proof. □
Example 1.
Let D = { 1 ( 30 ) , 2 ( 1 ) , 3 ( 2 ) , 4 ( 2 ) , 5 ( 3 ) , 6 ( 1 ) , 7 ( 1 ) , 8 ( 1 ) } . Then, by the definition of omega invariant, we have Ω ( D ) = 30 ( 1 2 ) + 1 ( 2 2 ) + 2 ( 3 2 ) + 2 ( 4 2 ) + 3 ( 5 2 ) + 1 ( 6 2 ) + 1 ( 7 2 ) + 1 ( 8 2 ) = 0 . We shall form several realizations of D as a connected unicyclic graph with maximum cycle length n a 1 = 11 and observe that the realization obtained according to the final algorithm gives us the smallest second Zagreb index.
To apply our algorithm (Theorem 1), we start with a cycle graph C n a 1 = C 11 and label its vertices as in Figure 1a. Then we label one of the vertices, say v 1 by the largest vertex degree, which is 8, see Figure 1b. At the second step, we pick up the smallest two degrees at non-pendant vertices, which are 2 and 3 and assign them to two adjacent vertices of v 1 , say v 2 and v n a 1 = v 11 as in Figure 1c. Then we follow the steps in the algorithm to reach the final labeling with minimum second Zagreb index, see Figure 2.
Here, the pendant edges are omitted in all figures as they do not affect the value of the second Zagreb index of all realizations, and they make the figures crowded. Therefore, for example, in Figure 1c, there are normally 3 2 = 1 pendant edges at v 11 and 8 2 = 6 pendant edges at v 1 . But they are not drawn in the figures throughout the paper for the above reason. In Figure 3, three random examples of realizations are illustrated.

3. Maximum Values of Second Zagreb Index of Unicyclic Graphs Having Maximum Cycle Length

Secondly, we consider the problem of finding the maximum values of the second Zagreb index amongst all connected unicyclic realizations of some D having maximum cycle length. The following algorithm gives us the graph with this property:
Theorem 2 (Maximum second Zagreb index algorithm).
Let D = { 1 ( a 1 ) , 2 ( a 2 ) , , Δ ( a Δ ) } be a unicyclic degree sequence. Let G = G i ( n a 1 ) be a connected realization of D constructed by the following algorithm. Then, the maximum value of the second Zagreb index amongst all realizations of D with maximum cycle length is obtained for G:
  • Assign the largest vertex degree to a vertex, say v 1 .
  • Assign the next largest vertex degree to one of the two vertices adjacent to v 1 , say v 2 and assign the second largest vertex degree to the adjacent vertex with largest vertex degree so far, that is v 1 . So let us call this vertex by v 3 .
  • For all the remaining vertex degrees, assign the largest value to the vertex that is adjacent to the larger of the two vertices at both ends of the labeled vertices. If any placement violates the alternating large/small rule, swapping the offending pair reduces the sum by the rearrangement inequality, hence our labeling is optimal.
Proof .
To obtain the largest value of the second Zagreb index amongst all connected unicyclic realizations of D having maximum cycle length, we must multiply the large values by large values. By Lemma 2, each swap strictly increases the local product. This proves the algorithm. □
The main idea that we utilize in this algorithm is very simple and depends on the rearrangement inequality: To obtain the larger values of the second Zagreb index amongst all connected unicyclic realizations of D having maximum cycle length, we have to select the correct ordering of the n a 1 positive integers placed on a cycle graph so that the sum of all possible products of the successive pairs of those integers gives us the higher sums. Naturally, to obtain a higher sum, we must multiply large numbers by large numbers. Similarly, to obtain a higher sum, we must multiply large numbers by small numbers. We illustrate the algorithm in the following example:
Example 2.
Let D = { 1 ( 124 ) , 5 ( 1 ) , 8 ( 1 ) , 9 ( 2 ) , 10 ( 1 ) , 11 ( 2 ) , 12 ( 1 ) , 13 ( 1 ) , 14 ( 1 ) , 15 ( 1 ) , 16 ( 1 ) , 17 ( 1 ) } be a set. As Ω ( D ) = 0 , all connected realizations of D will be unicyclic. Amongst those, the ones with maximum cycle length will have a cycle of length n a 1 = 13 . Now form a cycle graph C 13 as in Figure 4a. For each vertex degree d i in D that is greater than 2, we add d i 2 pendant edges to the corresponding vertex. According to our algorithm, as the largest vertex degree in D is 17, say for the vertex v 1 , we add 17 2 = 15 pendant edges to v 1 , see Figure 4b. At the end, we do this for all vertices with degree greater than 2 on the unique cycle. Figure 4c shows the beginning step of the algorithm where the successive vertices v 2 , v 1 and v 13 are added the required numbers of pendant edges.
Figure 5 shows the completed labeling of the 13-cycle with the largest possible second Zagreb index 1845, where the pendant edges are also counted in the calculation of M 2 . Once more, note that we start with the largest vertex degree, place the next largest two on both sides of the first vertex, and continue with the remaining largest vertex degree in the same fashion as explained in Theorem 2.

4. Conclusions

In [2], it was shown that the length of the unique cycle could be any integer between 1 and n a 1 where a 1 is the number of pendant vertices in the graph. In the particular case where the cycle has the maximum length, we obtain the ideal situation where all the pendant vertices are adjacent to the support vertices lying only on the unique cycle. This makes it easy to calculate any index, as the contribution of the pendant edges to such indices is fixed, implying that we can only calculate these indices for the edges on the cycle. In this paper, two novel algorithms are introduced to find the extremal values of the second Zagreb index. Some potential extensions (acyclic, bicyclic, etc.) can also be studied, but one needs further hypotheses to study such graphs. As open problems, we propose the following questions: Could these algorithms be extended to all other degree-based indices and to all other topological indices? We believe that it would be possible to give several algorithms for acyclic, bicyclic, tricyclic and k-cyclic graphs to generalize the algorithmic approach given here. But the situation is different when the graph is unicyclic, that is, the omega invariant is zero. We are sure of what we have as possible realizations of such a degree sequence. In all other cases, one needs to know more information, which makes it much more difficult. In the future, we hope to find these conditions and have the general case.

Funding

The author has no external funding.

Data Availability Statement

The original contributions presented in the study are included in the article; further inquiries can be directed to the corresponding author.

Conflicts of Interest

The author acknowledges that there is no potential conflict of interest with anybody else. No part of it has been published or simultaneously submitted to any other journals.

References

  1. Delen, S.; Yurttas, A.; Togan, M.; Cangul, I.N. Omega invariant of graphs and cyclicness. Appl. Sci. 2019, 21, 91–95. [Google Scholar]
  2. Delen, S.; Cangul, I.N. A new graph invariant. Turk. J. Anal. Number Theory 2018, 6, 30–33. [Google Scholar] [CrossRef]
  3. Gutman, I.; Trinajstic, N. Graph theory and molecular orbitals III, Total π-electron energy of alternant hydrocarbons. Chem. Phys. Lett. 1972, 17, 535–538. [Google Scholar] [CrossRef]
  4. Das, K.C. Maximizing the sum of the squares of the degrees of a graph. Discret. Math. 2004, 285, 57–66. [Google Scholar] [CrossRef]
  5. Das, K.C. Sharp bounds for the sum of the squares of the degrees of a graph. Kragujev. J. Math. 2003, 25, 31–49. [Google Scholar]
  6. Das, K.C. On comparing Zagreb indices of graphs. MATCH Commun. Math. Comput. Chem. 2010, 63, 433–440. [Google Scholar]
  7. Das, K.C.; Gutman, I. Some properties of the second Zagreb index. MATCH Commun. Math. Comput. Chem. 2004, 52, 103–112. [Google Scholar]
  8. Das, K.C.; Gutman, I.; Horoldagva, B. Comparison between Zagreb indices and Zagreb coindices. MATCH Commun. Math. Comput. Chem. 2012, 68, 189–198. [Google Scholar]
  9. Das, K.C.; Gutman, I.; Zhou, B. New upper bounds on Zagreb indices. J. Math. Chem. 2009, 46, 514–521. [Google Scholar] [CrossRef]
  10. Das, K.C.; Xu, K.; Gutman, I. On Zagreb and Harary indices. MATCH Commun. Math. Comput. Chem. 2013, 70, 301–314. [Google Scholar]
  11. Delen, S.; Cangul, I.N. Extremal Problems on Components and Loops in Graphs. Acta Math. Sin. Engl. Ser. 2019, 35, 161–171. [Google Scholar] [CrossRef]
  12. Cvetkovski, Z. Inequalities-Theorems, Techniques and Selected Problems; Springer: Berlin/Heidelberg, Germany, 2012. [Google Scholar]
Figure 1. (a) C 11 , (b) C 11 with v 1 labeled (Step 2) and (c) C 11 with v 1 , v 2 , v 11 are labeled (Step 3). Pendant edges are omitted for clarity.
Figure 1. (a) C 11 , (b) C 11 with v 1 labeled (Step 2) and (c) C 11 with v 1 , v 2 , v 11 are labeled (Step 3). Pendant edges are omitted for clarity.
Mathematics 13 02475 g001
Figure 2. The connected unicyclic realization of D having maximum cycle length 11 which has the minimum second Zagreb index.
Figure 2. The connected unicyclic realization of D having maximum cycle length 11 which has the minimum second Zagreb index.
Mathematics 13 02475 g002
Figure 3. (ac) Some other connected unicyclic realizations of D having maximum cycle length.
Figure 3. (ac) Some other connected unicyclic realizations of D having maximum cycle length.
Mathematics 13 02475 g003
Figure 4. (a) C 13 , (b) C 13 with v 1 labeled and (c) C 13 with v 1 , v 2 , v 13 labeled.
Figure 4. (a) C 13 , (b) C 13 with v 1 labeled and (c) C 13 with v 1 , v 2 , v 13 labeled.
Mathematics 13 02475 g004
Figure 5. A connected unicyclic realization of D having maximum cycle length 13, which has the maximum second Zagreb index 1845, where the pendant edges also contributed to the M 2 giving the final labeling with maximal second Zagreb index.
Figure 5. A connected unicyclic realization of D having maximum cycle length 13, which has the maximum second Zagreb index 1845, where the pendant edges also contributed to the M 2 giving the final labeling with maximal second Zagreb index.
Mathematics 13 02475 g005
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content.

Share and Cite

MDPI and ACS Style

Ozden Ayna, H. Extremal Values of Second Zagreb Index of Unicyclic Graphs Having Maximum Cycle Length: Two New Algorithms. Mathematics 2025, 13, 2475. https://doi.org/10.3390/math13152475

AMA Style

Ozden Ayna H. Extremal Values of Second Zagreb Index of Unicyclic Graphs Having Maximum Cycle Length: Two New Algorithms. Mathematics. 2025; 13(15):2475. https://doi.org/10.3390/math13152475

Chicago/Turabian Style

Ozden Ayna, Hacer. 2025. "Extremal Values of Second Zagreb Index of Unicyclic Graphs Having Maximum Cycle Length: Two New Algorithms" Mathematics 13, no. 15: 2475. https://doi.org/10.3390/math13152475

APA Style

Ozden Ayna, H. (2025). Extremal Values of Second Zagreb Index of Unicyclic Graphs Having Maximum Cycle Length: Two New Algorithms. Mathematics, 13(15), 2475. https://doi.org/10.3390/math13152475

Note that from the first issue of 2016, this journal uses article numbers instead of page numbers. See further details here.

Article Metrics

Back to TopTop