Next Article in Journal
Spiking Neural Networks Optimized by Improved Cuckoo Search Algorithm: A Model for Financial Time Series Forecasting
Previous Article in Journal
Advanced Sales Route Optimization Through Enhanced Genetic Algorithms and Real-Time Navigation Systems
Previous Article in Special Issue
Impossibility Results for Byzantine-Tolerant State Observation, Synchronization, and Graph Computation Problems
 
 
Font Type:
Arial Georgia Verdana
Font Size:
Aa Aa Aa
Line Spacing:
Column Width:
Background:
Article

A New Algorithm for Computing the Distance and the Diameter in Circulant Graphs

Polydisciplinary Faculty of Safi, Cadi Ayyad University, B.P. 4162, Safi 46000, Morocco
*
Author to whom correspondence should be addressed.
Algorithms 2025, 18(5), 261; https://doi.org/10.3390/a18050261
Submission received: 28 March 2025 / Revised: 26 April 2025 / Accepted: 28 April 2025 / Published: 1 May 2025
(This article belongs to the Special Issue Graph Theory and Algorithmic Applications: Theoretical Developments)

Abstract

In the present study, we focus on circulant graphs, C n ( S ) , with set of vertices { 0 , 1 , , n 1 } and in which two distinct vertices i and j are adjacent if and only if | i j | n S , where S is a generating set. Despite their regularity, there are currently no established formulas to accurately determine the distance and the diameter of circulant graphs. In light of this context, we present in this paper a novel approach, which relies on a simple algorithm, capable of yielding formulas for the distance and the diameter of circulant graphs without implementing any graph.
MSC:
68R01; 68R10; 05C12; 05C85; 05C75

1. Introduction

Given n 5 , D = { 1 , 2 , , n 2 } , and a generating set S D , the circulant graph C n ( S ) has { 0 , 1 , , n 1 } as a vertex set and in which two distinct vertices i and j are adjacent if and only if | i j | n S , where | x | n = min ( | x | , n | x | ) is the circular distance modulo n. We can use C n ( { s 1 , s 2 , , s k } ) , or simply C n ( s 1 , s 2 , , s k ) , to denote the circulant graph on n vertices, with respect to the connection set S = { s 1 , s 2 , , s k } , where 1 s 1 < s 2 < < s k n 2 .
Remark that C n ( 1 ) is the cycle C n , while C n ( D ) is the complete graph K n . For example, the circulant graphs C 24 ( 4 , 8 ) and C 24 ( 1 , 8 ) are illustrated in Figure 1.
The diameter of circulant graphs has been the subject of various investigations, with both theoretical and algorithmic contributions. Marklof and Strömbergsson [1] analyzed the asymptotic behavior of diameters in random circulant graphs, showing they scale as n 1 / k for 2k-regular graphs. Lewis [2] explored the degree-diameter problem for circulant graphs of degrees 10 and 11, while Bevan et al. [3] proposed constructions for large circulant graphs with fixed diameter and arbitrary degree. Previous studies have produced theoretical bounds, both upper and lower, (see [4,5]). In terms of algorithms, Wong and Coppersmith were pioneers in presenting the problem and suggested a heuristic algorithm to tackle it [6]. Moreover, Zerovnik and Pisanski delved into this topic and devised an algorithm to calculate the diameter of C n ( 1 , s ) with a runtime complexity of O ( log ( n ) ) [7].
Our primary goal isn’t just to develop an algorithm for computing the diameter for a given circulant graph. Instead, we aim to derive a new algorithm that calculates the diameter without the need to implement the graph itself, optimizing both space and time efficiency. Another key objective is for this new algorithm to provide theoretical formulas for the distance and diameter of any circulant graph. This is crucial, as having such formulas significantly contributes to several key areas, including graph labeling and packing coloring. Moreover, they enhance the traceability of circulant graphs and provide precise formulas for their upper traceable numbers. Other parameters that depend on the diameter can also have their formulas determined.
However, this undertaking comes with significant challenges. Despite the regular structure and vertex-transitivity of circulant graphs, even a slight alteration, like changing the graph’s order, completely transforms the graph, affecting the values of distance and diameter. This complexity highlights the intricate nature of analyzing circulant graphs and emphasizes the difficulties in deriving theoretical formulas for their distance and diameter.
Boesch and Tindell demonstrated in [8] that circulant graphs with different generating sets can still be isomorphic, indicating that it is unnecessary to study the diameter of all circulant graphs individually. Moreover, the cardinality of S inversely affects the diameter of the circulant graph C n ( S ) : a larger cardinality of S results in a smaller diameter. For instance, C n ( D ) is isomorphic to the complete graph K n with an order of n and a diameter of 1. If S = D X , where | X | = 1 or | X | = 2 , then d i a m ( C n ( S ) ) = 2 [9]. Therefore, it is both challenging and crucial to study circulant graphs with generators S of smaller cardinality, for instance | S | = 2 . However, for any circulant graph C n ( S ) with generator S = { s 1 , s 2 } satisfying g c d ( n , s 1 ) = 1 or g c d ( n , s 2 ) = 1 , C n ( S ) is isomorphic to C n ( 1 , s ) (see Theorem 1). Hence, our focus in this paper is on the connection set S = { 1 , s } , where s is an integer satisfying 2 s n 2 .
Theorem 1.
Let n 6 and let 2 s 1 < s 2 n 2 such that g c d ( n , s 1 ) = 1 or g c d ( n , s 2 ) = 1 . Therefore, C n ( s 1 , s 2 ) is isomorphic to C n ( 1 , s ) , where s . s 1 s 2 ( mod n ) or s . s 1 n s 2 ( mod n ) .
Proof. 
Without loss of generality, we assume that g c d ( n , s 1 ) = 1 (the same reasoning applies when g c d ( n , s 2 ) = 1 ). Let V ( C n ( 1 , s ) ) = { 0 , 1 , , n 1 } . We define the following permutation:
σ : V ( C n ( 1 , s ) ) { 0 , 1 , , n 1 } i σ ( i ) = i . s 1 ( mod n )
By construction, σ is surjective. Let i , j V ( C n ( 1 , s ) ) such that σ ( i ) = σ ( j ) . So, i . s 1 j . s 1 ( mod n ) . Which means that ( i j ) s 1 0 ( mod n ) . Since g c d ( n , s 1 ) = 1 and s 1 0 , we get i j = 0 . Thus, i = j . Consequently, σ is bijective.
Since C n ( 1 , s ) and C n ( s 1 , s 2 ) are vertex-transitive graphs, it suffices to verify that for a vertex i 0 , ( 0 , i ) E ( C n ( 1 , s ) ) if and only if ( 0 , σ ( i ) ) C n ( s 1 , s 2 ) . Recall that in this proof, all calculations are done modulo n. Let i V ( C n ( 1 , s ) ) . If ( 0 , i ) E ( C n ( 1 , s ) ) then | i | n { 1 , s } . | i | n = 1 means that i = 1 or i = n 1 . Moreover, σ ( 1 ) = s 1 and σ ( n 1 ) = ( n 1 ) . s 1 s 1 ( mod n ) . Therefore, ( 0 , σ ( i ) ) E ( C n ( s 1 , s 2 ) ) . If | i | n = s then i = s or i = n s . Thus, σ ( s ) = s . s 1 s 2 ( mod n ) . So, σ ( s ) S . Also, σ ( n s ) = ( n s ) . s 1 s 2 ( mod n ) , i.e., σ ( n s ) S . Therefore, if | i | n = s then ( 0 , σ ( i ) ) E ( C n ( s 1 , s 2 ) ) .
Conversely, if ( 0 , σ ( i ) ) E ( C n ( s 1 , s 2 ) ) ) then, | σ ( i ) | n { s 1 , s 2 } . | σ ( i ) | n = s 1 means that σ ( i ) = s 1 or n σ ( i ) = s 1 . So, i . s 1 = s 1 or n i . s 1 = s 1 . Since g c d ( n , s 1 ) = 1 , i = 1 ( mod n ) or i = 1 ( mod n ) . Thus, i = 1 or i = n 1 . Hence, ( 0 , i ) E ( C n ( 1 , s ) ) . If | σ ( i ) | n = s 2 , then σ ( i ) = s 2 or n σ ( i ) = s 2 . So, i . s 1 = s 2 or n i . s 1 = s 2 . Thus, i . s 1 = s . s 1 or i . s 1 = s . s 1 . Since g c d ( n , s 1 ) = 1 , i = s ( mod n ) or i = s ( mod n ) . Therefore, i = s ( mod n ) or i = n s ( mod n ) . Hence, ( 0 , i ) E ( C n ( 1 , s ) ) . Consequently, C n ( s 1 , s 2 ) is isomorphic to C n ( 1 , s ) .    □
Subsequently, we will focus only on the following problem.
Problem 1.
Given n , s , determine d i a m ( C n ( 1 , s ) ) .
To solve this problem, we develop a new algorithm in this paper that calculates the diameter of circulant graphs C n ( 1 , s ) without implementing any graph. This innovative method, which aids in finding distances within a circulant graph, enables us to derive exact formulas for the diameter of C n ( 1 , s ) across a wide range of n and s combinations. (See Table 1, where n = λ s + γ , λ = n s ,   n γ ( mod s ) , s = a γ + b , a = s γ , s b ( mod γ ) , p 0 = λ + γ 2 , p 1 = γ b + ( a + 1 ) λ + 1 2 , p 2 = γ + b + ( a 1 ) λ + 1 2 , p 3 = b + a λ + 1 2 , p 4 = ( γ + b ) ( a λ λ + 1 ) , and e = min { max { p 1 , p 3 } , max { p 0 , p 2 } } ).

2. Definitions and Notations

To develop our new algorithm, it is necessary to define new notions and techniques, which is the purpose of this section.
Proposition 1
([8]). The circulant graph C n ( s 1 , s 2 , , s k ) is connected if and only if g c d ( n , s 1 , s 2 , , s k ) = 1 .
Remark that in Figure 1, the graph C 24 ( 1 , 8 ) is connected, while the graph C 24 ( 4 , 8 ) is not connected.
Proposition 2
([8]).  All connected circulants are Hamiltonian.
Definition 1.
A walk is a sequence within a graph that consists of vertices and edges, where both edges and vertices can be revisited. A path, however, is a type of walk where no edges or vertices are repeated.
Definition 2.
In C n ( 1 , s ) , a path from a vertex i to another vertex j is denoted as P ( i , j ) and is represented as the pair ( α a ± , β c ± ) , where:
  • The symbol a (or c) indicates that P ( i , j ) traverses outer (or inner) edges.
  • α (or β) denotes the number of outer (or inner) edges.
  • The symbol + (or −) indicates that P ( i , j ) follows the clockwise (or counterclockwise) direction.
Remark 1.
Let i and j be two vertices of C n ( 1 , s ) . The path P ( i , j ) connecting these vertices can be realized in several ways:
1. 
The notation P ( i , j ) = ( α a ± , β c ± ) represents a path where P ( i , j ) moves along α outer edges either in the clockwise ( + ) or counterclockwise ( ) direction, before continuing through β inner edges either in the clockwise ( + ) or counterclockwise ( ) direction.
2. 
The notation P ( i , j ) = ( β c ± , α a ± ) represents a path where P ( i , j ) traverses β inner edges in the clockwise ( + ) or counterclockwise ( ) direction before proceeding through α outer edges in the clockwise ( + ) or counterclockwise ( ) direction.
3. 
The notation P ( i , j ) = ( α a ± , 0 ) represents a path where P ( i , j ) exclusively traverses α outer edges in the clockwise ( + ) or counterclockwise ( ) direction.
4. 
The notation P ( i , j ) = ( 0 , β c ± ) represents a path where P ( i , j ) exclusively traverses β inner edges in the clockwise ( + ) or counterclockwise ( ) direction.
Notation 1.
Let i and j be two vertices of C n ( 1 , s ) .
1. 
An outer (or inner) edge connecting the vertices i and j and following the clockwise ( + ) or counterclockwise ( ) direction is represented as i a ± j (or i c ± j ), respectively.
2. 
The length of the path P ( i , j ) is denoted by 𝓁 ( P ( i , j ) ) , the number of outer edges in P ( i , j ) is represented by 𝓁 a ( P ( i , j ) ) , and the number of inner edges in P ( i , j ) is denoted by 𝓁 c ( P ( i , j ) ) . Thus, 𝓁 ( P ( i , j ) ) = 𝓁 a ( P ( i , j ) ) + 𝓁 c ( P ( i , j ) ) .
Example 1.
Let us focus on the graph C 10 ( 1 , 4 ) presented in Figure 2.
If we choose an arbitrary vertex within the graph, such as vertex 6, there will exist multiple paths from vertex 0 to vertex 6. For illustrative purposes, we provide several of these paths in Table 2.
Definition 3.
Let i , j V ( C n ( 1 , s ) ) . Let P ( i , j ) and Q ( i , j ) be two paths in C n ( 1 , s ) . P ( i , j ) is equivalent to Q ( i , j ) , denoted P ( i , j ) Q ( i , j ) , if and only if 𝓁 ( P ( i , j ) ) = 𝓁 ( Q ( i , j ) ) , 𝓁 a ( P ( i , j ) ) = 𝓁 a ( Q ( i , j ) ) , 𝓁 c ( P ( i , j ) ) = 𝓁 c ( Q ( i , j ) ) , and that P ( i , j ) and Q ( i , j ) take the same direction.
Example 2.
In Example 1, P ( 6 , 9 ) = ( 1 a , 1 c + ) is equivalent to P ( 0 , 3 ) = ( 1 a , 1 c + ) because 𝓁 ( P ( 6 , 9 ) ) = 𝓁 ( P ( 0 , 3 ) ) = 2 , 𝓁 a ( P ( 6 , 9 ) ) = 𝓁 a ( P ( 0 , 3 ) ) = 1 , 𝓁 c ( P ( 6 , 9 ) ) = 𝓁 c ( P ( 0 , 3 ) ) = 1 , and that P ( 6 , 9 ) and P ( 0 , 3 ) take the same direction.
Lemma 1.
Consider two vertices i and j belonging to the vertex set V ( C n ( 1 , s ) ) of the circulant graph C n ( 1 , s ) . Let P ( i , j ) and Q ( i , j ) be two distinct paths within C n ( 1 , s ) . The relation denoted by ≈ is an equivalence relation defined on the set of paths in C n ( 1 , s ) .
Proof. 
The proof is immediate.    □
Observations 
  • Let us recall that since circulants belong to the family of Cayley graphs, any undirected circulant graph is vertex-transitive. Consequently, for any pair of vertices i and j within C n ( S ) , their distance, denoted as d ( i , j ) , can be equivalently expressed as d ( 0 , z ) , where z = j i , if i < j , n i + j , otherwise .
  • Since circulants are vertex-transitive and symmetric, the maximum distance among all pairs of vertices in C n ( 1 , s ) must occur for vertices i such that 1 i n 2 . However, d ( 0 , 1 ) = d ( 0 , n 1 ) = 1 . Thus, we have d i a m ( C n ( 1 , s ) ) = max { d ( 0 , i ) : 2 i n 2 } .
Henceforth, in this work, we specifically focus on paths leading from vertex 0 to another vertex i in C n ( 1 , s ) , denoted as P ( i ) . The distance of P ( i ) is represented as d ( i ) .
Example 3.
Consider the graph C 10 ( 1 , 4 ) depicted in Figure 2. Here, we provide examples of some equivalent paths in C 10 ( 1 , 4 ) :
  • P ( 6 , 9 ) = ( 1 a , 1 c + ) is equivalent to P ( 3 ) = ( 1 a , 1 c + ) ;
  • P ( 6 , 2 ) = ( 0 , 1 c ) is equivalent to P ( 6 ) = ( 0 , 1 c ) ;
Lemma 2.
For any vertex i in C n ( 1 , s ) , there exists a path that connects vertex 0 to i, following a sequence of traversing all its outer edges before proceeding to its inner edges, or conversely, traversing all its inner edges before entering its outer edges.
Proof. 
Let i be a vertex of C n ( 1 , s ) . Without loss of generality, suppose that W is an arbitrary walk in C n ( 1 , s ) leading from vertex 0 to vertex i by traversing α a + , β a , γ c + and λ c , of length 𝓁 ( W ) = α + β + γ + λ . In such a case, there exists a path P ( i ) in C n ( 1 , s ) that traverses all its outer edges before entering its inner edges, or vice versa, as represented below.
P ( i ) = ( ( α β ) a + , ( γ λ ) c + ) if α β and γ λ , ( ( β α ) a , ( λ γ ) c ) if α β and γ λ , ( ( α β ) a + , ( λ γ ) c ) if α β and γ λ , ( ( β α ) a , ( γ λ ) c + ) if α β and γ λ .
Thus,
𝓁 ( P ( i ) ) = ( α β ) + ( γ λ ) if α β and γ λ , ( β α ) + ( λ γ ) if α β and γ λ , ( α β ) + ( λ γ ) if α β and γ λ , ( β α ) + ( γ λ ) if α β and γ λ .
It is evident that 𝓁 ( P ( i ) ) 𝓁 ( W ) . Therefore, for all vertices i V ( C n ( 1 , s ) ) in the graph C n ( 1 , s ) , there exists a path leading from vertex 0 to vertex i by traversing all its outer edges before entering its inner edges, or vice versa.
Assume now that P ( i ) is an arbitrary path in C n ( 1 , s ) leading from vertex 0 to vertex i by traversing α a + , β a , γ c + and λ c . In the same manner, it can be proven that there exists a path P ( i ) equivalent to P ( i ) leading from vertex 0 to vertex i by traversing all its outer edges before entering its inner edges, or vice versa.    □
Example 4.
Let us consider the graph C 10 ( 1 , 4 ) presented in Figure 2. Without loss of generality, let W be an arbitrary walk in C 10 ( 1 , 4 ) leading from vertex 0 to vertex 6, with W taking the edges 1 a + ,   1 a ,   2 c + , and 3 c . The representation of W is as follows:
0 a + 1 c + 5 c + 9 a 8 c 4 c 0 c 6 .
By Lemma 2, there exists a path P ( 6 ) leading from vertex 0 to vertex 6, defined as P ( 6 ) = ( ( 1 1 ) a + , ( 3 2 ) c ) = ( 0 , 1 c ) . We observe that 𝓁 ( P ( 6 ) ) = 1 , which is less than 𝓁 ( W ) = 7 . Thus, for vertex 6, there exists a path P ( 6 ) that traverses all its outer edges before entering its inner edges.
In the same graph of Example 1, P 3 ( 6 ) is an arbitrary path in C 10 ( 1 , 4 ) leading from vertex 0 to vertex 6, by taking the edges 1 a + , 1 a and 4 c + . The representation of P 3 ( 6 ) is as follows:
0 a + 1 c + 5 c + 9 c + 3 a 2 c + 6 .
There exists the path P 4 ( 6 ) , from Example 1, leading from vertex 0 to vertex 6, defined as P 4 ( 6 ) = ( ( 1 1 ) a + , 4 c + ) = ( 0 , 4 c + ) . We observe that 𝓁 ( P 4 ( 6 ) ) = 4 , which is less than 𝓁 ( P 3 ( 6 ) ) = 6 . Thus, for vertex 6, there exists a path P 4 ( 6 ) that traverses all its outer edges before entering its inner edges.
Notation 2.
Let i be a vertex of C n ( 1 , s ) , and let t be an integer. We denote the integers q, q t , q ¯ t , r, r t , and r ¯ t as follows:
  • i r ( mod s ) , and q : = i s ,
  • t n + i r t ( mod s ) , and q t : = t n + i s ,
  • t n i r ¯ t ( mod s ) , and q ¯ t : = t n i s .
Remark 2.
  • In C n ( 1 , s ) , the inner edges form g c d ( n , s ) cycles of length n g c d ( n , s ) .
  • We remark that by Proposition 2, if g c d ( n , s ) = 1 , then C n ( 1 , s ) is Hamiltonian. Thereby, the inner edges form one cycle of length n.
  • Let i be a vertex of C n ( 1 , s ) . If g c d ( n , s ) = 1 , then the number of inner edges in P ( i ) cannot exceed n 1 . Thus, the number of inner edges is bounded as follows: 1 q ¯ t n 1 and 1 q t n 1 . Thus, t n + i s t n + i s n 1 and t n i s t n i s n 1 . Therefore, 1 t s .
  • Otherwise, if g c d ( n , s ) 1 then the number of inner edges is bounded as follows: 1 q ¯ t < n g c d ( n , s ) and 1 q t < n g c d ( n , s ) . Therefore, 1 t s g c d ( n , s ) .

3. Algorithm Computing the Diameter of Circulant Graphs

Our objective is to establish formulas that yield precise values for the diameter of C n ( 1 , s ) across all potential combinations of n and s. Given that the diameter represents the greatest distance between any pair of vertices, and the distance corresponds to the shortest path, we have thoroughly examined the characteristics of paths in C n ( 1 , s ) . Consequently, we have discovered the existence of numerous equivalent paths leading from vertex 0 to another vertex i within C n ( 1 , s ) . Our approach revolves around identifying and characterizing this equivalent class of paths in C n ( 1 , s ) , which allows us to derive the exact values for the diameter of the graph.
Lemma 3.
Let t be an integer such that 1 t s g c d ( n , s ) . For every vertex i of C n ( 1 , s ) , there exists a class of pairwise non-equivalent paths C = { P 1 ( i ) ,   P 2 ( i ) ,   P 1 , t ( i ) ,   P 2 , t ( i ) ,   P 3 , t ( i ) ,   P 4 , t ( i ) } such that
  • P 1 ( i ) = ( r a + , q c + ) of length 𝓁 1 ( i ) = r + q .
  • P 2 ( i ) = ( ( s r ) a , ( q + 1 ) c + ) of length 𝓁 2 ( i ) = 1 + s r + q .
  • P 1 , t ( i ) = ( r t a + , q t c + ) of length 𝓁 1 , t ( i ) = r t + q t .
  • P 2 , t ( i ) = ( ( s r t ) a , ( q t + 1 ) c + ) of length 𝓁 2 , t ( i ) = 1 + s r t + q t .
  • P 3 , t ( i ) = ( r ¯ t a , q ¯ t c ) of length 𝓁 3 , t ( i ) = r ¯ t + q ¯ t .
  • P 4 , t ( i ) = ( ( s r ¯ t ) a + , ( q ¯ t + 1 ) c ) of length 𝓁 4 , t ( i ) = 1 + s r ¯ t + q ¯ t .
Proof. 
Let i be a vertex of C n ( 1 , s ) and t be an integer such that 1 t s g c d ( n , s ) .
By the definition of r, we have i = q s + r . In this case, we consider the path P ( i ) represented as follows 0 a + 1 a + 2 a + a + r c + r + s c + r + 2 s c + c + r + q s = i . We have P 1 ( i ) = ( r a + , q c + ) and, 𝓁 1 ( i ) = r + q .
Remark that i can be also written as i = ( q + 1 ) s + ( r s ) . We consider, in this case, the path P ( i ) represented as follows 0 a n 1 a n 2 a a n ( s r ) c + n ( s r ) + s c + n ( s r ) + 2 s c + c + n ( s r ) + ( q + 1 ) s = n + i ( i mod n ) . We have P 2 ( i ) = ( ( s r ) a , ( q + 1 ) c + ) and, 𝓁 2 ( i ) = 1 + s r + q .
By the definition of q t , we have t n + i = q t s + r t . In this case, we consider the path P ( i ) represented as follows 0 a + 1 a + 2 a + a + r t c + r t + s c + r t + 2 s c + c + r t + q t s = t n + i ( i mod n ) . We have P 3 , t ( i ) = ( r t a + , q t c + ) and, 𝓁 1 , t ( i ) = r t + q t .
Remark that i can be written as t n + i = ( q t + 1 ) s + ( r t s ) . In this case, we consider the path P ( i ) represented as follows 0 a n 1 a n 2 a a n ( s r t ) c + n ( s r t ) + s c + n ( s r t ) + 2 s c + c + n ( s r t ) + ( q t + 1 ) s = ( t + 1 ) n + i ( i mod n ) . We have P 2 , t ( i ) = ( ( s r t ) a , ( q t + 1 ) c + ) and, 𝓁 2 , t ( i ) = 1 + s r t + q t .
By the definition of q ¯ t , we have t n i = q ¯ t s + r ¯ t . In this case, we consider the path P ( i ) represented as follows 0 a n 1 a n 2 a a r ¯ t c r ¯ t s c r ¯ t 2 s c c r ¯ t q ¯ t s = t n + i ( i mod n ) . We have P 3 , t ( i ) = ( r ¯ t a , q ¯ t c ) and, 𝓁 3 , t ( i ) = r ¯ t + q ¯ t .
Remark that i can be written as t n i = ( q ¯ t + 1 ) s + ( r ¯ t s ) . We consider, in this case, the path P ( i ) represented as follows 0 a + 1 a + 2 a + a + ( r ¯ t s ) c ( r ¯ t s ) s c ( r ¯ t s ) 2 s c c ( r ¯ t s ) ( q ¯ t + 1 ) s = t n + i ( i mod n ) . We have P 4 , t ( i ) = ( ( s r ¯ t ) a + , ( q ¯ t + 1 ) c ) and, 𝓁 4 , t ( i ) = 1 + s r ¯ t + q ¯ t .    □
Remark 3.
In certain instances where specific values of n and s are considered, the set C may include certain walks. In such cases, these walks will be equivalent to other paths within C but possess smaller lengths.
Proposition 3.
Each path present within the class C forms an equivalence class.
Proof. 
Let i be a vertex of C n ( 1 , s ) , and let t be an integer satisfying 1 t s gcd ( n , s ) . The set of paths P comprises the following six equivalence classes:
  • [ P 1 ( i ) ] = { P ( i ) P : P 1 ( i ) P ( i ) } ;
  • [ P 2 ( i ) ] = { P ( i ) P : P 2 ( i ) P ( i ) } ;
  • [ P 1 , t ( i ) ] = { P ( i ) P : P 1 , t ( i ) P ( i ) } ;
  • [ P 2 , t ( i ) ] = { P ( i ) P : P 2 , t ( i ) P ( i ) } ;
  • [ P 3 , t ( i ) ] = { P ( i ) P : P 3 , t ( i ) P ( i ) } ;
  • [ P 4 , t ( i ) ] = { P ( i ) P : P 4 , t ( i ) P ( i ) } .
In fact, without loss of generality, assuming that W is an arbitrary walk in C n ( 1 , s ) leading from vertex 0 to vertex i, we can apply Lemma 2 to establish the existence of a path Q ( i ) that traverses all its outer edges before entering its inner edges, or vice versa. Let us assume, without loss of generality, that Q ( i ) = ( α a ± , β c ± ) . In this case, there exists a path P ( i ) C that satisfies the following conditions: 𝓁 ( P ( i ) ) = 𝓁 ( Q ( i ) ) , 𝓁 a ( P ( i ) ) = 𝓁 a ( Q ( i ) ) , 𝓁 c ( P ( i ) ) = 𝓁 c ( Q ( i ) ) , and both P ( i ) and Q ( i ) take the same direction. In other words, there exists P ( i ) C such that P ( i ) Q ( i ) .    □
Example 5.
Consider the graph C 10 ( 1 , 4 ) presented in Figure 2. Without loss of generality, let W be an arbitrary walk in C 10 ( 1 , 4 ) leading from vertex 0 to vertex 6, with W taking the edges 1 a + , 1 a , 2 c + , and 3 c . The walk W is represented as follows:
0 a + 1 c + 5 c + 9 a 8 c 4 c 0 c 6 .
By Lemma 2, there exists a path Q ( 6 ) such that Q ( 6 ) = ( ( 1 1 ) a + , ( 3 2 ) c ) = ( 0 , 1 c ) . We note that 𝓁 ( Q ( 6 ) ) = 1 , which is smaller than 𝓁 ( W ) = 7 . Moreover, by Lemma 3, for t = 1 , we have n i = 10 6 = 4 = s . Thus, P 3 , 1 ( 6 ) = ( 0 , 1 c ) . Hence, Q ( 6 ) P 3 , 1 ( 6 ) . Consequently, Q ( 6 ) [ P 3 , 1 ( 6 ) ] .
As per the definition, the distance corresponds to the shortest path. The following result provides the distance between vertex 0 and any vertex i in C n ( 1 , s ) .
Lemma 4.
Let t be an integer such that 1 t s g c d ( n , s ) . For all i V ( C n ( 1 , s ) ) ,
d ( i ) = min ( 𝓁 1 ( i ) , 𝓁 2 ( i ) , 𝓁 1 , t ( i ) , 𝓁 2 , t ( i ) , 𝓁 3 , t ( i ) , 𝓁 4 , t ( i ) ) .
The algorithm for computing the diameter of C n ( 1 , s ) can be outlined as follows (Algorithm 1):
Algorithm 1 Diameter of C n ( 1 , s )
  • Input: n and s
  • Step 1: Compute gcd ( n , s )
  • Step 2: For i { 2 , , n 2 } and 1 t s gcd ( n , s ) , compute
                        d ( i ) = min ( 𝓁 1 ( i ) , 𝓁 2 ( i ) , 𝓁 1 , t ( i ) , 𝓁 2 , t ( i ) , 𝓁 3 , t ( i ) , 𝓁 4 , t ( i ) )
  • Output:  d i a m ( C n ( 1 , s ) ) = max 2 i n 2 d ( i ) .
Remark 4.
Algorithm 1 allows us to calculate the diameter without implementing any graph. Unlike classic methods that require the implementation of a graph, our algorithm only requires two integers, n and s, to provide the diameter of the circulant graph C n ( 1 , s ) . This significantly optimizes space. Another important point is that classic diameter calculation algorithms simply yield a numerical value, whereas our algorithm provides exact formulas for the diameter of the circulant graph C n ( 1 , s ) for any n and s.
In the upcoming section, we present exact formulas for the diameter of C n ( 1 , s ) for almost all values of n and s, which have been established and computed using techniques applied in Algorithm 1.

4. Diameter Formulas for Circulant Graphs

Throughout this section, we assume that n 5 and 2 s n 2 . We express n as n = λ s + γ , where γ is an integer satisfying the condition 0 γ < s .
Theorem 2
([4]).  If n = λ s , d i a m ( C n ( 1 , s ) ) = λ + s 1 2 .
As we delve into proving the upcoming results, we consider two cases: when λ > γ and when λ γ . We first address the scenario where λ > γ . Given that we have already discussed, in Theorem 2, the case where γ equals 0, our focus now shifts to situations where λ > γ > 0 . Within this context, we explore the parity of the integers n and s across four scenarios: when both n and s are even, when both are odd, when n is even and s is odd, and when n is odd and s is even. Before delving into this, we introduce the following lemma, which will aid in proving the subsequent results.
Lemma 5.
Let i be a vertex of C n ( 1 , s ) . Let d and k be two integers such that n 2 k < n . If for each vertex i k , either 𝓁 1 ( i ) d , 𝓁 2 ( i ) d , 𝓁 3 , 1 ( i ) d , or 𝓁 4 , 1 ( i ) d , then d ( i ) d for all vertices i of C n ( 1 , s ) .
Proof. 
Let i V ( C n ( 1 , s ) ) and let d , k N such that n 2 k < n . We discuss the following cases:
Case 1.  𝓁 1 ( i ) d  for  i k
According to Lemma 4, we find that d ( i ) = min ( 𝓁 1 ( i ) , 𝓁 2 ( i ) , 𝓁 1 , t ( i ) , 𝓁 2 , t ( i ) , 𝓁 3 , t ( i ) , 𝓁 4 , t ( i ) ) . Hence, d ( i ) 𝓁 1 ( i ) d for i k . However, considering that n 2 k < n , we can see that d ( i ) d for i n 2 . Additionally, we have 𝓁 1 ( i ) = r + i s = r + n ( n i ) s = 𝓁 3 , 1 ( n i ) , which implies that similarly, by Lemma 4, d ( n i ) 𝓁 3 , 1 ( n i ) d for i n 2 , i.e., d ( i ) d for i n 2 . Consequently, d ( i ) d for all vertices i of C n ( 1 , s ) .
Case 2.  𝓁 2 ( i ) d  for  i k
Utilizing Lemma 4, we derive that d ( i ) 𝓁 2 ( i ) d for i k . However, given that n 2 k < n , we note that d ( i ) d for i n 2 . We continue in the same manner as we did in the previous case, noting that this time, we have 𝓁 2 ( i ) = 1 + s r + i s = 1 + s r + n ( n i ) s = 𝓁 4 , 1 ( n i ) .
We establish the rest of the cases using the same approach as in Case 1, with the distinction being that in these instances 𝓁 3 , 1 ( i ) = 𝓁 1 ( n i ) and 𝓁 4 , 1 ( i ) = 𝓁 2 ( n i ) . □

4.1. Diameter of C n ( 1 , s ) When n Is Even and s Is Odd

Lemma 6.
When n is even and s is odd,
d i a m ( C n ( 1 , s ) ) λ 2 + s + 1 2 min ( γ 2 ,   s γ + 1 2 ) .
Proof. 
Let us denote M as the minimum value between γ 2 and s γ + 1 2 , and let i represent a vertex of C n ( 1 , s ) . According to Lemma 4, we find that d ( i ) min ( 𝓁 3 , 1 ( i ) , 𝓁 4 , 1 ( i ) ) , where 𝓁 3 , 1 ( i ) = r ¯ 1 + n i s and 𝓁 4 , 1 ( i ) = 1 + s r ¯ 1 + n i s . It is worth noting that if r ¯ 1 s + 1 2 , then min ( 𝓁 3 , 1 ( i ) , 𝓁 4 , 1 ( i ) ) = 𝓁 3 , 1 ( i ) ; otherwise, min ( 𝓁 3 , 1 ( i ) , 𝓁 4 , 1 ( i ) ) = 𝓁 4 , 1 ( i ) .
For i ( λ 2 + M ) s , we find that 𝓁 3 , 1 ( i ) r ¯ 1 + λ 2 M and 𝓁 4 , 1 ( i ) 1 + s r ¯ 1 + λ 2 M . If r ¯ 1 s + 1 2 , then d ( i ) 𝓁 3 , 1 ( i ) λ 2 + s + 1 2 M ; otherwise, d ( i ) 𝓁 4 , 1 ( i ) λ 2 + s + 1 2 M . Therefore, d ( i ) λ 2 + s + 1 2 M for i ( λ 2 + M ) s . By Lemma 5, if n 2 ( λ 2 + M ) s < n , then d ( i ) λ 2 + s + 1 2 M for all vertices i of C n ( 1 , s ) . Consequently, we will have d i a m ( C n ( 1 , s ) ) λ 2 + s + 1 2 M , which is the desired outcome. Hence, the remaining task is to prove that n 2 ( λ 2 + M ) s < n , a proof that will be presented in the following claim.
Claim 1.
n 2 ( λ 2 + M ) s < n .
Proof. 
It is worth noting that if γ is even (or odd), given that n is even and s is odd, we conclude that λ is also even (or odd). Also, if γ s + 1 2 , then M = γ 2 ; otherwise, M = s γ + 1 2 . Therefore, we will consider the following two cases:
Case 1.  γ s + 1 2
In this case, we have
( λ 2 + M ) s = ( λ 2 + γ 2 ) s = ( λ 1 2 + γ + 1 2 ) s , if γ is odd ( λ 2 + γ 2 ) s , if γ is even = ( λ + γ 2 ) s .
Thus,
  • n 2 ( λ + γ 2 ) s = λ s + γ 2 λ s + γ s 2 = γ ( 1 s ) 2 < 0 .
  • ( λ + γ 2 ) s n = ( λ + γ 2 ) s ( λ s + γ ) = s ( γ λ ) 2 γ 2 < 0 . (Since γ < λ , γ λ < 0 )
Case 2.  γ > s + 1 2
In this case,
( λ 2 + M ) s = ( λ 2 + s γ + 1 2 ) s = ( λ 1 2 + s γ + 2 2 ) s , if γ is odd ( λ 2 + s γ + 1 2 ) s , if γ is even = ( λ + s γ + 1 2 ) s .
Hence,
  • n 2 ( λ + s γ + 1 2 ) s = λ s + γ 2 λ s + s 2 γ s + s 2 = ( γ s ) + ( γ s s 2 ) 2 0 . ( γ s < s 2 )
  • ( λ + s γ + 1 2 ) s n = ( λ + s γ + 1 2 ) s ( λ s + γ ) = s ( s λ γ ) + ( s 2 γ ) 2 < 0 .
(We have γ > s + 1 2 , so 2 γ s > 1 . Thus, s 2 γ < 0 . On the other hand, since λ > γ and γ > s + 1 2 , then λ > s + 1 2 . Thus, s λ < s 1 2 . Moreover, we have γ < s 1 2 . Hence, s λ γ < s 1 2 + s 1 2 < 0 ) □
Lemma 7.
Suppose n is even and s is odd. There is a vertex i in C n ( 1 , s ) such that,
d ( i ) = λ 2 + s + 1 2 min ( γ 2 , s γ + 1 2 ) .
Proof. 
Let d = λ 2 + s + 1 2 min ( γ 2 , s γ + 1 2 ) . Let R = { 1 , 2 , , s 1 } be the set of all the possible values of γ . This set can be partitioned into: R 1 = { 2 m 1 : 1 m s + 3 4 } , R 2 = { 2 m : 1 m s + 3 4 } , R 3 = { s 2 m + 2 : 2 m s 1 4 } , and R 4 = { s 2 m + 1 : 1 m s 5 4 } . Note that R 3 = R 4 = when s 5 . Moreover, R = R 1 R 2 R 3 R 4 . In fact, when γ is odd (i.e., γ { R 1 , R 3 } ), we have R 1 = { 1 , 3 , 5 , , 2 s + 3 4 1 } and R 3 = { s 2 s 1 4 + 2 , , s 2 } . It is easy to verify that, when s is odd, we obtain 2 s + 3 4 1 + 2 = s 2 s 1 4 + 2 . Similarly, when γ is even, we have 2 s + 3 4 + 2 = s 2 s 5 4 + 1 .
Case 1.  γ R 1
Since γ is odd, min ( γ 2 , s γ + 1 2 ) = min ( γ + 1 2 , s γ + 2 2 ) = γ + 1 2 if γ s + 1 2 , s γ + 2 2 otherwise .
However, γ = 2 m 1 , where 1 m s + 3 4 . Thus, if s 1 ( mod 4 ) , then γ s + 1 2 . Otherwise, if s 3 ( mod 4 ) , then γ s 1 2 . Hence, min ( γ + 1 2 , s γ + 2 2 ) = γ + 1 2 . Moreover, λ is odd and λ > γ 1 . Thus, λ 3 . Therefore, when γ R 1 , d = λ + 1 2 + s 1 2 γ + 1 2 + 1 .
Case 1.1.  γ = 1
In this case, d = λ + s 2 . Let i = λ 1 2 s + s + 1 2 be a vertex of C n ( 1 , s ) . We have,
  • 𝓁 1 ( i ) = 𝓁 2 ( i ) = λ 1 2 + s + 1 2 = d ;
Let 1 t s g c d ( n , s ) be an integer. We have t n + i = ( t λ + λ 1 2 ) s + t + s + 1 2 . If t + s + 1 2 < s then,
  • 𝓁 1 , t ( i ) = t ( λ + 1 ) + λ 1 2 + s + 1 2 > d ;
  • 𝓁 2 , t ( i ) = t ( λ 1 ) + λ 1 2 + s + 1 2 > d ;
If t + s + 1 2 s , i.e., t s 1 2 , then t n + i = ( t λ + λ 1 2 + λ ) s + γ where λ 1 , γ 0 and t + s + 1 2 = λ s + γ .
  • 𝓁 1 , t ( i ) = t λ + λ 1 2 + λ + γ t λ + λ + 1 2 > t + λ + 1 2 . So, 𝓁 1 , t ( i ) > s 1 2 + λ + 1 2 . Thus, 𝓁 1 , t ( i ) > d ;
  • 𝓁 2 , t ( i ) = 1 + s γ + t λ + λ 1 2 + λ t λ + λ + 1 2 + 1 . Thus, 𝓁 2 , t ( i ) > d ;
We have t n i = ( ( t 1 ) λ + λ + 1 2 ) s + t s + 1 2 . If t s + 1 2 < 0 , then t n i = ( ( t 1 ) λ + λ 1 2 ) s + t + s 1 2 ,
  • 𝓁 3 , t ( i ) = ( t 1 ) ( λ + 1 ) + λ + 1 2 + s 1 2 λ + 1 2 + s 1 2 d ;
  • 𝓁 4 , t ( i ) = ( t 1 ) ( λ 1 ) + λ 1 2 + s + 1 2 λ + 1 2 + s 1 2 d ;
If 0 t s + 1 2 < s , i.e., t s + 1 2 , then t n i = ( ( t 1 ) λ + λ + 1 2 ) s + t s + 1 2 .
  • 𝓁 3 , t ( i ) = ( t 1 ) λ + λ + 1 2 + t s + 1 2 ( t 1 ) λ + λ + 1 2 > t + λ 1 2 . So, 𝓁 3 , t ( i ) > d .
  • 𝓁 4 , t ( i ) = 1 + s ( t s + 1 2 ) + ( t 1 ) λ + λ + 1 2 ( t 1 ) λ + λ + 1 2 + 1 . Thus, 𝓁 4 , t ( i ) > d .
Thus, by Lemma 4, we have d ( i ) = 𝓁 1 ( i ) = 𝓁 2 ( i ) = d .
Case 1.2.  γ 3
If s = 5 then, we have γ = 3 ,   λ 5 , and d = λ + 1 2 + 1 . Let i = ( λ + 1 2 + 1 ) s be a vertex of C n ( 1 , s ) . By a simple calculation of the lengths 𝓁 1 ( i ) to 𝓁 4 , t ( i ) represented in Lemma 3, and by applying Lemma 4, we obtain d ( i ) = 𝓁 1 ( i ) = d .
If s > 5 then, γ 3 , λ 5 , and d = λ + 1 2 + s + 1 2 γ + 1 2 . Let i = λ + 1 2 s + γ + 1 2 + s + 1 2 be a vertex of C n ( 1 , s ) . Since s > 5 and γ s + 1 2 , we obtain γ + 1 2 + s + 1 2 < s . Note that γ 1 2 1 γ + 1 2 + 2 because γ 3 . By a simple calculation of the lengths 𝓁 1 ( i ) to 𝓁 4 , t ( i ) represented in Lemma 3, and by applying Lemma 4, we obtain d ( i ) = 𝓁 2 ( i ) = d .
Case 2.  γ R 2
Since γ is even, min ( γ 2 , s γ + 1 2 ) = min ( γ 2 , s γ + 1 2 ) = γ 2 if γ s + 1 2 , s γ + 1 2 otherwise .
Moreover, γ = 2 m where 1 m s + 3 4 . Thus, for s odd, we obtain γ s + 3 2 . Hence, we have γ 2 , λ 4 , s 3 , and d = λ 2 + s + 1 2 s γ + 1 2 if γ = s + 3 2 , λ 2 + s + 1 2 γ 2 if γ s + 1 2 .
Case 2.1.  γ = s + 3 2
In this case, d = λ 2 + γ 2 . Let i = λ 2 s + γ 2 be a vertex of C n ( 1 , s ) . Note that since s > γ , we obtain s γ 2 > γ 2 . By a simple calculation of the lengths 𝓁 1 ( i ) to 𝓁 4 , t ( i ) represented in Lemma 3, and by applying Lemma 4, we obtain d ( i ) = 𝓁 1 ( i ) = d .
Case 2.2.  γ s + 1 2
If s = 3 , then γ = 2 , λ 4 , and d = λ 2 + 1 . Let i = ( λ 2 + 1 ) s be a vertex of C n ( 1 , s ) . By a simple calculation of the lengths 𝓁 1 ( i ) to 𝓁 4 , t ( i ) represented in Lemma 3, and by applying Lemma 4, we obtain d ( i ) = 𝓁 1 ( i ) = d .
If s > 3 , then γ 2 , λ 4 , and d = λ 2 + s + 1 2 γ 2 . Let i = λ 2 s + s + 1 2 + γ 2 be a vertex of C n ( 1 , s ) . Since s > 3 and γ s + 1 2 , we have s + 1 2 + γ 2 < s . Note that γ 2 1 γ 2 + 1 because γ 2 . By a simple calculation of the lengths 𝓁 1 ( i ) to 𝓁 4 , t ( i ) represented in Lemma 3, and by applying Lemma 4, we obtain d ( i ) = 𝓁 2 ( i ) = d .
Case 3.  γ R 3
In this case, γ = s 2 m + 2 where 2 m s 1 4 . If s 1 ( mod 4 ) , then γ s + 5 2 . Otherwise, if s 3 ( mod 4 ) , then γ s + 3 2 . Since γ is odd and γ s + 1 2 , we get min ( γ 2 , s γ + 1 2 ) = min ( γ + 1 2 , s γ + 2 2 ) = s γ + 2 2 . Therefore, γ 3 , λ 5 , s 7 (when s 5 , R 3 = ), and d = λ + 1 2 + s + 1 2 s γ + 2 2 . Let i = ( λ + 1 2 s γ + 2 2 ) s + s + 1 2 be a vertex C n ( 1 , s ) . By a simple calculation of the lengths 𝓁 1 ( i ) to 𝓁 4 , t ( i ) represented in Lemma 3, and by applying Lemma 4, we obtain d ( i ) = 𝓁 1 ( i ) = 𝓁 2 ( i ) = d .
Case 4.  γ R 4
Here, we have γ = s 2 m + 1 where 1 m s 5 4 . If s 1 ( mod 4 ) , then γ s + 7 2 . Otherwise, if s 3 ( mod 4 ) , then γ s + 5 2 . Moreover, since γ is even and γ s + 1 2 , we have min ( γ 2 , s γ + 1 2 ) = min ( γ 2 , s γ + 1 2 ) = s γ + 1 2 . Therefore, γ 4 , λ 6 , s 7 (when s 5 , R 3 = ), and d = λ 2 + s + 1 2 s γ + 1 2 . Let i = ( λ 2 s γ + 1 2 + 1 ) s + s 1 2 be a vertex C n ( 1 , s ) . By a simple calculation of the lengths 𝓁 1 ( i ) to 𝓁 4 , t ( i ) represented in Lemma 3, and by applying Lemma 4, we obtain d ( i ) = 𝓁 1 ( i ) = d . □
Thus, the following theorem follows from Lemmas 6 and 7.
Theorem 3.
When n is even and s is odd,
d i a m ( C n ( 1 , s ) ) = λ 2 + s + 1 2 min ( γ 2 , s γ + 1 2 ) .

4.2. Diameter of C n ( 1 , s ) When Both n and s Are Even

Lemma 8.
When both n and s are even,
d i a m ( C n ( 1 , s ) ) λ 2 + s γ 2 if γ 2 s 2 4 , λ 2 + γ 2 o t h e r w i s e .
Proof. 
Since both n and s are even, γ is also even regardless of whether λ is even or odd. Let i represent a vertex of C n ( 1 , s ) .
Case 1.  γ 2 s 2 4
According to Lemma 4, we find that d ( i ) min ( 𝓁 3 , 1 ( i ) , 𝓁 4 , 1 ( i ) ) , where 𝓁 3 , 1 ( i ) = r ¯ 1 + n i s and 𝓁 4 , 1 ( i ) = 1 + s r ¯ 1 + n i s . It is worth noting that if r ¯ 1 s 2 , then min ( 𝓁 3 , 1 ( i ) , 𝓁 4 , 1 ( i ) ) = 𝓁 3 , 1 ( i ) ; otherwise, if r ¯ 1 s 2 + 1 , then min ( 𝓁 3 , 1 ( i ) , 𝓁 4 , 1 ( i ) ) = 𝓁 4 , 1 ( i ) . For i ( λ 2 + γ 2 ) s , we find that 𝓁 3 , 1 ( i ) r ¯ 1 + λ 2 γ 2 and 𝓁 4 , 1 ( i ) 1 + s r ¯ 1 + λ 2 γ 2 . If r ¯ 1 s 2 , then d ( i ) 𝓁 3 , 1 ( i ) λ 2 + s 2 γ 2 ; otherwise, if r ¯ 1 s 2 + 1 , then d ( i ) 𝓁 4 , 1 ( i ) λ 2 + s 2 γ 2 . Therefore, d ( i ) λ 2 + s 2 γ 2 for i ( λ 2 + γ 2 ) s . By Lemma 5, if n 2 ( λ 2 + γ 2 ) s < n , then d ( i ) λ 2 + s 2 γ 2 for all vertices i of C n ( 1 , s ) . Consequently, we will have d i a m ( C n ( 1 , s ) ) λ 2 + s 2 γ 2 , which is the desired outcome. Hence, the remaining task is to prove that n 2 ( λ 2 + γ 2 ) s < n , a proof that will be presented in the following claim.
Claim 2.
n 2 ( λ 2 + γ 2 ) s < n .
Proof. 
If λ is even, then,
  • n 2 ( λ 2 + γ 2 ) s = λ s + γ 2 λ s + γ s 2 = γ ( 1 s ) 2 < 0 .
  • ( λ 2 + γ 2 ) s n = λ s + γ s 2 λ s 2 γ 2 = s ( γ λ ) 2 γ 2 < 0 . ( γ < λ , so γ λ < 0 )
Otherwise, if λ is odd, then,
  • ( λ 1 2 + γ 2 ) s n = λ s s + γ s 2 λ s 2 γ 2 = s ( γ λ ) s 2 γ 2 < 0 . ( γ < λ , so γ λ < 0 )
  • n 2 ( λ 1 2 + γ 2 ) s = λ s + γ 2 λ s s + γ s 2 = γ + s γ s 2 < 0 .
(Assume that γ + s γ s > 0 , i.e., s ( 1 γ ) + γ > 0 , which implies that s ( γ 1 ) < γ . Thus, s < γ γ 1 . Contradiction with the fact that s > γ . Hence, γ + s γ s < 0 ) □
Case 2.  γ > 2 s 2 4
For i ( λ 2 + γ 2 ) s , we have 𝓁 1 ( i ) λ 2 + γ 2 . Therefore, according to Lemma 4, we find that d ( i ) 𝓁 1 ( i ) λ 2 + γ 2 . Moreover, as per the previous claim, we showed that n 2 ( λ 2 + γ 2 ) s < n , thus, by Lemma 5, d ( i ) λ 2 + γ 2 for all vertices i of C n ( 1 , s ) . Consequently, d i a m ( C n ( 1 , s ) ) λ 2 + γ 2 . □
Lemma 9.
Suppose that both n and s are even. There is a vertex i in C n ( 1 , s ) such that,
d ( i ) = λ 2 + s γ 2 i f γ 2 s 2 4 , λ 2 + γ 2 o t h e r w i s e .
Proof. 
Let d = λ 2 + s γ 2 i f γ 2 s 2 4 , λ 2 + γ 2 o t h e r w i s e .
In this case, γ is even and s 4 because if s = 2 , then γ = 0 (see Theorem 2).
Case 1.  γ 2 s 2 4
Case 1.1.  λ is even
In this case, γ 2 , λ 4 , s 4 , and d = λ 2 + s γ 2 . Let i = ( λ 2 γ 2 ) s + s 2 be a vertex of C n ( 1 , s ) . Table 3 represents a simple calculation of the lengths 𝓁 1 ( i ) to 𝓁 4 , t ( i ) provided in Lemma 3.
Thus, by Lemma 4, we have d ( i ) = 𝓁 1 ( i ) = d .
Case 1.2.  λ is odd
If γ = 2 then, λ 3 , s 4 , and d = λ + 1 2 + s 2 2 . Let i = λ 1 2 s + s 2 + 1 be a vertex of C n ( 1 , s ) . Note that since s 4 , we have s 2 + 1 < s . By a simple calculation of the lengths 𝓁 1 ( i ) to 𝓁 4 , t ( i ) represented in Lemma 3, and by applying Lemma 4, we obtain d ( i ) = 𝓁 2 ( i ) = d .
If γ 4 then, λ 5 , s 6 , and d = λ + 1 2 + s γ 2 . Let i = λ + 1 2 s + γ 2 + s 2 + 1 be a vertex of C n ( 1 , s ) . Since s > 4 and γ s 2 2 , we have γ 2 + s 2 + 1 < s . Note that γ 2 2 > γ 2 + 1 because γ 4 . By a simple calculation of the lengths 𝓁 1 ( i ) to 𝓁 4 , t ( i ) represented in Lemma 3, and by applying Lemma 4, we obtain d ( i ) = 𝓁 2 ( i ) = d .
Case 2.  γ > 2 s 2 4
If λ is even, then γ 2 , λ 4 , s 4 , and d = λ 2 + γ 2 . Let i = n 2 be a vertex of C n ( 1 , s ) . Note that since s > γ , we have s γ 2 > γ 2 . By a simple calculation of the lengths 𝓁 1 ( i ) to 𝓁 4 , t ( i ) represented in Lemma 3, and by applying Lemma 4, we obtain d ( i ) = 𝓁 1 ( i ) = d .
If λ is odd then, γ 2 , λ 3 , s 4 , and d = λ 1 2 + γ 2 . Let i = λ 1 2 s + γ 2 be a vertex of C n ( 1 , s ) . Since s > γ , we have s γ 2 > γ 2 . Similarly, by applying Lemma 4, we obtain d ( i ) = 𝓁 1 ( i ) = d . □
Thus, the following theorem follows from Lemmas 8 and 9.
Theorem 4.
When both n and s are even,
d i a m ( C n ( 1 , s ) ) = λ 2 + s γ 2 i f γ 2 s 2 4 , λ 2 + γ 2 o t h e r w i s e .

4.3. Diameter of C n ( 1 , s ) When Both n and s Are Odd

Theorem 5.
When both n and s are odd,
d i a m ( C n ( 1 , s ) ) = λ 2 + s + 1 2 min ( γ + 1 2 , s γ + 2 2 ) .
Proof. 
Let us denote M as the minimum value between γ + 1 2 and s γ + 2 2 , and let i represent a vertex of C n ( 1 , s ) . We prove, by the same method as in Lemma 6, that for i ( λ 2 + M ) s , d ( i ) λ 2 + s + 1 2 M . Then we prove, similarly as in Claim 1, that n 2 ( λ 2 + M ) s < n . Hence, by applying Lemma 5, we find that d ( i ) λ 2 + s + 1 2 M for all vertices i in C n ( 1 , s ) . Hence, d i a m ( C n ( 1 , s ) ) λ 2 + s + 1 2 min ( γ + 1 2 , s γ + 2 2 ) .
Let d = λ 2 + s + 1 2 min ( γ + 1 2 , s γ + 2 2 ) . Let R = { 1 , 2 , , s 1 } be the set of all the possible values of γ . This set can be partitioned into: R 1 = { 2 m 1 : 1 m s + 3 4 } , R 2 = { 2 m 2 : 2 m s + 5 4 } , R 3 = { s 2 m + 2 : 2 m s 1 4 } , and R 4 = { s 2 m + 3 : 2 m s 1 4 } . Moreover, R = R 1 R 2 R 3 R 4 . In fact, when γ is odd (i.e., γ { R 1 , R 3 } ), we have R 1 = { 1 , 3 , 5 , , 2 s + 3 4 1 } and R 3 = { s 2 s 1 4 + 2 , , s 2 } . It is easy to verify that, when s is odd, we obtain 2 s + 3 4 1 + 2 = s 2 s 1 4 + 2 . Similarly, when γ is even, we have 2 s + 5 4 2 + 2 = s 2 s 1 4 + 3 .
Case 1.  γ R 1
Since γ is odd, min ( γ + 1 2 , s γ + 2 2 ) = min ( γ + 1 2 , s γ + 2 2 ) = γ + 1 2 if γ s + 1 2 , s γ + 2 2 otherwise .
However, we have γ = 2 m 1 where 1 m s + 3 4 . Thus, if s 1 ( mod 4 ) , then γ s + 1 2 . Otherwise, if s 3 ( mod 4 ) , then γ s 1 2 . Hence, min ( γ + 1 2 , s γ + 2 2 ) = γ + 1 2 . Moreover, we have γ 1 , λ 2 , s 3 , and d = λ 2 + s + 1 2 γ + 1 2 . Let i = ( λ 2 1 ) s + s 1 2 + γ + 1 2 be a vertex of C n ( 1 , s ) . Since γ s 1 2 , we have s 1 2 + γ + 1 2 < s . Note that γ + 1 2 1 γ + 1 2 + 1 because γ 1 . Table 4 represents a simple calculation of the lengths 𝓁 1 ( i ) to 𝓁 4 , t ( i ) provided in Lemma 3.
Thus, by Lemma 4, we have d ( i ) = 𝓁 2 ( i ) = d .
Case 2.  γ R 2
Since γ is even, min ( γ + 1 2 , s γ + 2 2 ) = min ( γ + 2 2 , s γ + 3 2 ) = γ + 2 2 if   γ s + 1 2 , s γ + 3 2 if   γ s + 3 2 .
However, we have γ = 2 m 2 where 2 m s + 5 4 . Thus, if s 1 ( mod 4 ) , then γ s + 3 2 . Otherwise, if s 3 ( mod 4 ) , then γ s + 1 2 . Hence, min ( γ + 1 2 , s γ + 2 2 ) = γ + 1 2 . Therefore, γ 2 , λ 3 , s 3 , and d = λ + 1 2 + s + 1 2 s γ + 3 2 if γ = s + 3 2 , λ + 1 2 + s + 1 2 γ + 2 2 if γ s + 1 2 .
Case 2.1.  γ = s + 3 2
In this case, d = λ + 1 2 + s 1 4 . Let i = λ + 1 2 s + s 1 4 be a vertex of C n ( 1 , s ) . Note that s s 1 4 > s 1 4 . By a simple calculation of the lengths 𝓁 1 ( i ) to 𝓁 4 , t ( i ) represented in Lemma 3, and by applying Lemma 4, we obtain d ( i ) = 𝓁 1 ( i ) = d .
Case 2.2.  γ s + 1 2
If s = 3 , then γ = 2 , λ 3 , and d = λ + 1 2 . Let i = λ + 1 2 s be a vertex of C n ( 1 , s ) . By a simple calculation of the lengths 𝓁 1 ( i ) to 𝓁 4 , t ( i ) represented in Lemma 3, and by applying Lemma 4, we obtain d ( i ) = 𝓁 1 ( i ) = d .
If s > 3 , then γ 2 , λ 3 , and d = λ + 1 2 + s + 1 2 γ + 2 2 . Let i = λ 1 2 s + s 1 2 + γ + 2 2 be a vertex of C n ( 1 , s ) . Since s > 3 and γ s + 1 2 , we get s 1 2 + γ + 2 2 < s . Note that γ + 2 2 > γ + 2 2 + 2 and γ 2 2 > γ + 2 2 + 1 because γ 2 . By a simple calculation of the lengths 𝓁 1 ( i ) to 𝓁 4 , t ( i ) represented in Lemma 3, and by applying Lemma 4, we obtain d ( i ) = 𝓁 2 ( i ) = d .
Case 3.  γ R 3
In this case, γ 3 , λ 4 , s 3 , and d = λ 2 + s + 1 2 s γ + 2 2 . Let i = ( λ 2 s γ + 2 2 ) s + s + 1 2 be a vertex of C n ( 1 , s ) . By a simple calculation of the lengths 𝓁 1 ( i ) to 𝓁 4 , t ( i ) represented in Lemma 3, and by applying Lemma 4, we obtain d ( i ) = 𝓁 1 ( i ) = 𝓁 2 ( i ) = d .
Case 4.  γ R 4
We have γ 4 , λ 5 , s 3 , and d = λ + 1 2 + s + 1 2 s γ + 3 2 . Let i = ( λ + 1 2 s γ + 3 2 ) s + s 1 2 be a vertex of C n ( 1 , s ) . By a simple calculation of the lengths 𝓁 1 ( i ) to 𝓁 4 , t ( i ) represented in Lemma 3, and by applying Lemma 4, we obtain d ( i ) = 𝓁 1 ( i ) = 𝓁 2 ( i ) = d .
Hence for all γ R , there exists a vertex i of C n ( 1 , s ) such that, d ( i ) = λ 2 + s + 1 2 M . Consequently, d i a m ( C n ( 1 , s ) ) = λ 2 + s + 1 2 min ( γ + 1 2 , s γ + 2 2 ) .

4.4. Diameter of C n ( 1 , s ) When n Is Odd and s Is Even

Lemma 10.
When n is odd and s is even,
d i a m ( C n ( 1 , s ) ) λ 2 + s 2 2 i f γ { 1 , s 1 } , λ 2 + s γ + 1 2 i f 3 γ 2 s 4 1 , λ 2 + γ 1 2 o t h e r w i s e .
Proof. 
Since n is odd and s is even, γ is odd regardless of whether λ is even or odd. Let i V ( C n ( 1 , s ) ) .
Case 1.  γ { 1 , s 1 }
For i ( λ 2 + 1 ) s , we find that 𝓁 3 , 1 ( i ) r ¯ 1 + λ 2 1 and 𝓁 4 , 1 ( i ) 1 + s r ¯ 1 + λ 2 1 . According to Lemma 4, if r ¯ 1 s 2 , then d ( i ) 𝓁 3 , 1 ( i ) λ 2 + s 2 2 ; otherwise, if r ¯ 1 s 2 + 1 , then d ( i ) 𝓁 4 , 1 ( i ) λ 2 + s 2 2 . Therefore, we find that d ( i ) λ 2 + s 2 2 for i ( λ 2 + 1 ) s . By Lemma 5, if n 2 ( λ 2 + 1 ) s < n , then d ( i ) λ 2 + s 2 2 for all vertices i of C n ( 1 , s ) . Consequently, we will have d i a m ( C n ( 1 , s ) ) λ 2 + s 2 2 , which is the desired outcome. Hence, the remaining task is to prove that n 2 ( λ 2 + 1 ) s < n , a proof that will be presented in the following claim.
Claim 3.
n 2 ( λ 2 + 1 ) s < n .
Proof. 
If λ is even, then,
  • n 2 ( λ 2 + 1 ) s n 2 ( λ 2 + 1 ) s λ s + γ 2 λ s + 2 s 2 γ 2 s 2 < 0 .
  • ( λ 2 + 1 ) s n = λ s + 2 s 2 λ s 2 γ 2 = s ( 2 λ ) 2 γ 2 < 0 . ( λ 2 even, so 2 λ < 0 )
Otherwise, if λ is odd, then,
  • n 2 ( λ 1 2 + 1 ) s n 2 ( λ 1 2 + 1 ) s λ s + γ 2 λ s s + 2 s 2 γ s 2 < 0 .
  • ( λ 1 2 + 1 ) s n = λ s s + 2 s 2 λ s 2 γ 2 = s ( 1 λ ) 2 γ 2 < 0 . ( λ 2 even, so 1 λ < 0 )
Case 2.  3 γ 2 s 4 1
For i ( λ 2 + γ 1 2 ) s , we find that 𝓁 3 , 1 ( i ) r ¯ 1 + λ 2 γ 1 2 and 𝓁 4 , 1 ( i ) 1 + s r ¯ 1 + λ 2 γ 1 2 . According to Lemma 4, if r ¯ 1 s 2 , then d ( i ) 𝓁 3 , 1 ( i ) λ 2 + s γ + 1 2 ; otherwise, if r ¯ 1 s 2 + 1 , then d ( i ) 𝓁 4 , 1 ( i ) λ 2 + s γ + 1 2 . Therefore, we find that d ( i ) λ 2 + s γ + 1 2 for i ( λ 2 + γ 1 2 ) s . By Lemma 5, if n 2 ( λ 2 + γ 1 2 ) s < n , then we will have d i a m ( C n ( 1 , s ) ) λ 2 + s γ + 1 2 . Hence, the remaining task is to prove that n 2 ( λ 2 + γ 1 2 ) s < n , a proof that will be presented in the following claim.
Claim 4.
n 2 ( λ 2 + γ 1 2 ) s < n .
Proof. 
If λ is even, then,
  • n 2 ( λ 2 + γ 1 2 ) s n 2 ( λ 2 + γ 1 2 ) s γ + s γ s 2 < 0 .
  • ( λ 2 + γ 1 2 ) s n = s ( γ λ ) s 2 γ 2 < 0 .
Otherwise, if λ is odd, then,
  • n 2 ( λ + γ 2 ) s n 2 ( λ + γ 2 ) s γ ( 1 s ) 2 < 0 .
  • ( λ + γ 2 ) s n = s ( γ λ ) 2 γ 2 < 0 .
Case 3.  s 2 γ < s 1
For i ( λ 2 + γ 1 2 ) s , we have 𝓁 1 ( i ) λ 2 + γ 1 2 . Therefore, according to Lemma 4, we find that d ( i ) 𝓁 1 ( i ) λ 2 + γ 1 2 . Moreover, as per the previous claim, we showed that n 2 ( λ 2 + γ 1 2 ) s < n , thus, by Lemma 5, d ( i ) λ 2 + γ 1 2 for all vertices i of C n ( 1 , s ) . Consequently, d i a m ( C n ( 1 , s ) ) λ 2 + γ 1 2 . □
Lemma 11.
Suppose that n is odd and s is even. There is a vertex i in C n ( 1 , s ) such that
d ( i ) = λ 2 + s 2 2 i f γ { 1 , s 1 } , λ 2 + s γ + 1 2 i f 3 γ 2 s 4 1 , λ 2 + γ 1 2 o t h e r w i s e .
Proof. 
Let d = λ 2 + s 2 2 if   γ { 1 , s 1 } , λ 2 + s γ + 1 2 if 3 γ 2 s 4 1 , λ 2 + γ 1 2 otherwise .
Case 1.  γ { 1 , s 1 }
If γ = 1 then, λ 2 , s 4 , and d = λ 2 + s 2 2 . Let i = ( λ 2 1 ) s + s 2 be a vertex of C n ( 1 , s ) . Table 5 represents a simple calculation of the lengths 𝓁 1 ( i ) to 𝓁 4 , t ( i ) provided in Lemma 3.
Thus, by Lemma 4, we have d ( i ) = 𝓁 1 ( i ) = d .
If γ = s 1 , then λ s , s 4 , and d = λ 2 + s 2 2 . Let i = ( λ 2 1 ) s + s 2 be a vertex of C n ( 1 , s ) . By a simple calculation of the lengths 𝓁 1 ( i ) to 𝓁 4 , t ( i ) represented in Lemma 3, and by applying Lemma 4, we obtain d ( i ) = 𝓁 1 ( i ) = d .
Case 2.  3 γ 2 s 4 1
If λ is even, then λ 4 , s 4 , and d = λ 2 + s 2 γ 1 2 . Let i = ( λ 2 γ 1 2 ) s + s 2 + 1 be a vertex of C n ( 1 , s ) . Note that since s 4 , we have s 2 + 1 < s . By a simple calculation of the lengths 𝓁 1 ( i ) to 𝓁 4 , t ( i ) represented in Lemma 3, and by applying Lemma 4, we obtain d ( i ) = 𝓁 2 ( i ) = d .
If λ is odd then, γ 3 , λ 5 , s 4 , and d = λ 1 2 + s 2 γ 1 2 . Let i = λ 1 2 s + γ 1 2 + s 2 + 1 be a vertex of C n ( 1 , s ) . Note that since γ s 2 1 and s 4 , we get γ 1 2 + s 2 + 1 < s . By a simple calculation of the lengths 𝓁 1 ( i ) to 𝓁 4 , t ( i ) represented in Lemma 3, and by applying Lemma 4, we obtain d ( i ) = 𝓁 2 ( i ) = d .
Case 3.  2 s 4 γ < s 1
We have γ 3 , λ 4 , s 4 , and d = λ 2 + γ 1 2 . Let i = λ 2 s + γ 1 2 be a vertex of C n ( 1 , s ) . Note that since s > γ , we have s γ 1 2 > γ + 1 2 . By a simple calculation of the lengths 𝓁 1 ( i ) to 𝓁 4 , t ( i ) represented in Lemma 3, and by applying Lemma 4, we obtain d ( i ) = 𝓁 1 ( i ) = d . This completes the proof. □
Thus, the following theorem follows from Lemmas 10 and 11.
Theorem 6.
When n is odd and s is even,
d i a m ( C n ( 1 , s ) ) = λ 2 + s 2 2 i f γ { 1 , s 1 } , λ 2 + s γ + 1 2 i f 3 γ 2 s 4 1 , λ 2 + γ 1 2 o t h e r w i s e .
Next, we discuss the case when γ 0 and λ γ .

4.5. Diameter of C n ( 1 , s ) When λ γ

Theorem 7
([4]).  Let s = a γ + b , a = s γ , and s b ( mod γ ) . Define p 0 = λ + γ 2 , p 1 = γ b + ( a + 1 ) λ + 1 2 , p 2 = γ + b + ( a 1 ) λ + 1 2 , p 3 = b + a λ + 1 2 , and p 4 = ( γ + b ) ( a λ λ + 1 ) . Let e = min { max { p 1 , p 3 } , max { p 0 , p 2 } } . If λ γ and b a λ + 1 , , then
d i a m ( C n ( 1 , s ) ) = p 1 1 i f   p 1 = p 2   a n d   p 4 1 ( mod 2 ) , e o t h e r w i s e .
For the remaining values of n and s, although our algorithm yields an exact value for the diameter of C n ( 1 , s ) , it does not provide a general explicit formula. To address this limitation, we proceed to present upper bounds on the diameter of C n ( 1 , s ) for all possible values of n and s in the upcoming section.

5. Upper Bound for the Diameter of Circulant Graphs

In 1990, Du et al. [10] gave the following upper bound on the diameter of C n ( 1 , s ) :
d i a m ( C n ( 1 , s ) ) max { n s + 1 , n n s s 2 , ( n s + 1 ) s n 1 } .
Another upper bound was given by Göbel and Neutel [11]:
d i a m ( C n ( 1 , s ) ) d i a m ( C n ( 1 , 2 ) ) = n + 2 4 .
Next, we present our upper bound on the diameter of C n ( 1 , s ) for n and s.
Theorem 8.
For all n and s ,
d i a m ( C n ( 1 , s ) ) n 2 s + s 2 .
Proof. 
If i n 2 , then 𝓁 1 ( i ) r + n 2 s and 𝓁 2 ( i ) 1 + s r + n 2 s . Since, by Lemma 4, d ( i ) min ( 𝓁 1 ( i ) , 𝓁 2 ( i ) ) , then d ( i ) n 2 s + s 2 . In fact, min ( 𝓁 1 ( i ) , 𝓁 2 ( i ) ) = 𝓁 1 ( i ) if r s 2 , and min ( 𝓁 1 ( i ) , 𝓁 2 ( i ) ) = 𝓁 1 ( i ) s 2 + n 2 s . If r > s 2 , then min ( 𝓁 1 ( i ) , 𝓁 2 ( i ) ) = 𝓁 2 ( i ) < 1 + s s 2 + n 2 s s 2 + n 2 s . Thus, for i n 2 ,   d ( i ) n 2 s + s 2 . Consequently, we conclude that d i a m ( C n ( 1 , s ) ) n 2 s + s 2 . □
By combining (1), (2), and (3), we obtain the following result.
Theorem 9.
For all n and s ,
d i a m ( C n ( 1 , s ) ) min ( max { n s + 1 , n n s s 2 , ( n s + 1 ) s n 1 } ,
n + 2 4 , n 2 s + s 2 ) .

6. Conclusions

In this paper, we have proposed a new algorithm for computing the diameter of circulant graphs of the form C n ( 1 , s ) without requiring the construction of the graph itself. This approach significantly improves both space and time efficiency, making it a practical tool for analyzing large graphs. By leveraging the structure of circulant graphs and focusing on the case where S = { 1 , s } , we derived exact formulas for distances and diameters that not only deepen our understanding of the metric properties of circulant graphs but also have important implications for related areas such as graph labeling, packing coloring, and the computation of traceable numbers. The proposed algorithm lays the groundwork for further exploration of efficient distance computation in more complex circulant structures and offers a new perspective on the combinatorial analysis of these graphs.

Author Contributions

Conceptualization, L.L.; Investigation, L.L. and M.K.; Methodology, L.L.; Software, L.L. and M.K.; Supervision, M.K.; Visualization, L.L.; Writing—original draft, L.L.; Writing—review & editing, L.L. All authors have read and agreed to the published version of the manuscript.

Funding

This research received no external funding.

Data Availability Statement

Data are contained within the article. The original contributions presented in this study are included in the article. Further inquiries can be directed to the corresponding author.

Conflicts of Interest

The authors declare no conflicts of interest.

References

  1. Marklof, J.; Strömbergsson, A. Diameters of random circulant graphs. Combinatorica 2013, 33, 429–466. [Google Scholar] [CrossRef]
  2. Lewis, R.R. The degree-diameter problem for circulant graphs of degrees 10 and 11. Discret. Math. 2018, 341, 2553–2566. [Google Scholar] [CrossRef]
  3. Bevan, D.; Erskine, G.; Lewis, R. Large circulant graphs of fixed diameter and arbitrary degree. arXiv 2015, arXiv:1506.04962. [Google Scholar] [CrossRef]
  4. Chen, B.; Xiao, W.; Parhami, B. Diameter formulas for a class of undirected double-loop networks. J. Interconnect. Netw. 2005, 6, 1–15. [Google Scholar] [CrossRef]
  5. Monakhova, E.A. A survey on undirected circulant graphs. Discret. Math. Algorithms Appl. 2012, 4, 1250002. [Google Scholar] [CrossRef]
  6. Wong, C.K.; Coppersmith, D. A combinatorial problem related to multimodule memory organizations. J. ACM 1974, 21, 392–402. [Google Scholar] [CrossRef]
  7. Zerovnik, J.; Pisanski, T. Computing the diameter in multiple-loop networks. J. Algorithms 1993, 14, 226–243. [Google Scholar] [CrossRef]
  8. Boesch, F.; Tindell, R. Circulants and their connectivities. J. Graph Theory 1984, 8, 487–499. [Google Scholar] [CrossRef]
  9. Loudiki, L.; Bidine, E.-Z.; Kchikech, M. Labeling Circulant Graphs: Distance Two Condition. Symmetry 2023, 15, 2160. [Google Scholar] [CrossRef]
  10. Du, D.-Z.; Hsu, D.F.; Li, Q.; Xu, J. A combinatorial problem related to distributed loop networks. Networks 1990, 20, 173–180. [Google Scholar] [CrossRef]
  11. Göbel, F.; Neutel, E.A. Cyclic graphs. Discret. Appl. Math. 2000, 99, 3–12. [Google Scholar] [CrossRef]
Figure 1. C 24 ( 4 , 8 ) and C 24 ( 1 , 8 ) .
Figure 1. C 24 ( 4 , 8 ) and C 24 ( 1 , 8 ) .
Algorithms 18 00261 g001
Figure 2. The circulant graph C 10 ( 1 , 4 ) .
Figure 2. The circulant graph C 10 ( 1 , 4 ) .
Algorithms 18 00261 g002
Table 1. Exact formulas for the diameter of circulant graphs C n ( 1 , s ) .
Table 1. Exact formulas for the diameter of circulant graphs C n ( 1 , s ) .
Diameter of C n ( 1 , s )
γ = 0 = λ + s 1 2 [4]
λ > γ n evens odd = λ 2 + s + 1 2 min ( γ 2 ,   s γ + 1 2 )
s even = λ 2 + s γ 2 if   γ 2 s 2 4 , λ 2 + γ 2 otherwise .
n odds odd = λ 2 + s + 1 2 min ( γ + 1 2 ,   s γ + 2 2 )
s even = λ 2 + s 2 2 if   γ { 1 , s 1 } , λ 2 + s γ + 1 2 if   3 γ 2 s 4 1 , λ 2 + γ 1 2 otherwise .
λ γ and b a λ + 1 = p 1 1 if   p 1 = p 2   and   p 4 1 ( mod 2 ) , e otherwise .       [4]
All n and s min ( max ( n s + 1 ,   n n s s 2 ,   ( n s + 1 ) s n 1 ) ,   n + 2 4 ,   n 2 s + s 2 )
Table 2. Examples of paths leading from the vertex 0 to the vertex 6 in C 10 ( 1 , 4 ) .
Table 2. Examples of paths leading from the vertex 0 to the vertex 6 in C 10 ( 1 , 4 ) .
P ( 0 , 6 ) Representation of P ( 0 , 6 ) 𝓁 a ( P ( 0 , 6 ) ) 𝓁 c ( P ( 0 , 6 ) ) 𝓁 ( P ( 0 , 6 ) )
= ( 2 a + , 1 c + ) 0 a + 1 a + 2 c + 6 213
= ( 2 a , 2 c + ) 0 a 9 a 8 c + 2 c + 6 224
= ( 0 , 4 c + ) 0 c + 4 c + 8 c + 2 c + 6 044
= ( 0 , 1 c ) 0 c 6 011
Table 3. Values of 𝓁 1 ( i ) , 𝓁 2 ( i ) , 𝓁 1 , t ( i ) , …, 𝓁 4 , t ( i ) .
Table 3. Values of 𝓁 1 ( i ) , 𝓁 2 ( i ) , 𝓁 1 , t ( i ) , …, 𝓁 4 , t ( i ) .
𝓁 1 ( i ) = λ 2 + s γ 2 = d
𝓁 2 ( i ) = λ 2 + s γ 2 + 1 > d
𝓁 1 , t ( i ) , 𝓁 2 , t ( i ) > λ 2 + s γ 2 if t γ + s 2 < s , λ 2 + s γ 2 + 1 if t γ + s 2 s . > d
𝓁 3 , t ( i ) > λ 2 + s + γ 2 if t γ s 2 < 0 , λ 2 + s γ 2 if 0 t γ s 2 < s , λ 2 + s + γ 2 + 1 if t γ s 2 s . > d
𝓁 4 , t ( i ) λ 2 + s γ 2 if t γ s 2 < 0 , > λ 2 + s γ 2 + 1 if 0 t γ s 2 < s , > λ 2 + s + γ 2 + 2 if t γ s 2 s . d
Table 4. Values of 𝓁 1 ( i ) , 𝓁 2 ( i ) , 𝓁 1 , t ( i ) , …, 𝓁 4 , t ( i ) .
Table 4. Values of 𝓁 1 ( i ) , 𝓁 2 ( i ) , 𝓁 1 , t ( i ) , …, 𝓁 4 , t ( i ) .
𝓁 1 ( i ) = λ 2 + s 1 2 + γ + 1 2 1 d
𝓁 2 ( i ) = λ 2 + s + 1 2 γ + 1 2 = d
𝓁 1 , t ( i ) , 𝓁 2 , t ( i ) > λ 2 + s + 1 2 γ + 1 2 if t γ + γ + 1 2 + s 1 2 < s , λ 2 + s + 1 2 γ + 1 2 if t γ + γ + 1 2 + s 1 2 s . > d
𝓁 3 , t ( i ) , 𝓁 4 , t ( i ) > λ 2 + s + 1 2 γ + 1 2 if t γ γ + 1 2 s 1 2 < s , λ 2 + s + 1 2 γ + 1 2 if t γ γ + 1 2 s 1 2 s . > d
Table 5. Values of 𝓁 1 ( i ) , 𝓁 2 ( i ) , 𝓁 1 , t ( i ) , …, 𝓁 4 , t ( i ) .
Table 5. Values of 𝓁 1 ( i ) , 𝓁 2 ( i ) , 𝓁 1 , t ( i ) , …, 𝓁 4 , t ( i ) .
𝓁 1 ( i ) = λ 2 + s 2 2 = d
𝓁 2 ( i ) = λ 2 + s 2 > d
𝓁 1 , t ( i ) , 𝓁 2 , t ( i ) > λ 2 + s 2 2 if t + s 2 < s , λ 2 + s 2 2 if t + s 2 s . > d
𝓁 3 , t ( i ) > λ 2 + s 2 2 if t s 2 < 0 , λ 2 + s 2 2 if 0 t s 2 < s . > d
𝓁 4 , t ( i ) λ 2 + s 2 2 if t s 2 < 0 , > λ 2 + s 2 2 if 0 t s 2 < s . d
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

Loudiki, L.; Kchikech, M. A New Algorithm for Computing the Distance and the Diameter in Circulant Graphs. Algorithms 2025, 18, 261. https://doi.org/10.3390/a18050261

AMA Style

Loudiki L, Kchikech M. A New Algorithm for Computing the Distance and the Diameter in Circulant Graphs. Algorithms. 2025; 18(5):261. https://doi.org/10.3390/a18050261

Chicago/Turabian Style

Loudiki, Laila, and Mustapha Kchikech. 2025. "A New Algorithm for Computing the Distance and the Diameter in Circulant Graphs" Algorithms 18, no. 5: 261. https://doi.org/10.3390/a18050261

APA Style

Loudiki, L., & Kchikech, M. (2025). A New Algorithm for Computing the Distance and the Diameter in Circulant Graphs. Algorithms, 18(5), 261. https://doi.org/10.3390/a18050261

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