Skip to Content
You are currently on the new version of our website. Access the old version .
AxiomsAxioms
  • Article
  • Open Access

5 November 2026

14 Pages

Average Fermat Difference on Unicyclic Graphs

and
School of Mathematics and Information Science, Shandong Technology and Business University, Yantai 264003, China
*
Author to whom correspondence should be addressed.
This article belongs to the Special Issue Advances and Applications in Graph Theory

Abstract

For a connected graph, the Fermat difference of three vertices is defined as the minimum sum of their distances to a common vertex minus half the sum of their pairwise distances. In this paper, we investigate the average Fermat difference of unicyclic graphs with prescribed order and cycle length. By establishing a projection identity, we reduce the problem to a weighted cubic form on the unique cycle. We obtain an exact formula for cycles and establish a sharp lower bound together with a characterization of all extremal graphs attaining equality. We further derive a general upper bound for unicyclic graphs with prescribed order and cycle length. Finally, we determine the maximum average Fermat difference among all unicyclic graphs of fixed order and characterize the corresponding extremal graphs.

1. Introduction

Distance-based graph invariants play a fundamental role in the study of graph structure and network topology. Among them, the shortest-path distance, also called the geodesic distance, is one of the most basic measures of connectivity. For a connected graph G of order n, the Wiener index is defined by
W ( G ) = ∑ { u , v } ⊆ V ( G ) d G ( u , v ) ,
where d G ( u , v ) denotes the length of a shortest path joining u and v. Introduced by Wiener [1] in his study of molecular structures and physical properties, this index has subsequently become an important subject in chemical graph theory and extremal graph theory. Its normalized form,
d ¯ ( G ) = W ( G ) n 2 ,
is the average geodesic distance of G. This quantity also plays a central role in network science, particularly in the characterization of the small-world phenomenon [2,3]. Average geodesic distances have been investigated for various structured graph families and self-similar networks; see, for example, the work of Wang et al. [4] on Sierpiński networks.
A natural extension of ordinary graph distance is obtained by considering distances among more than two vertices. Chartrand et al. [5] introduced the concept of Steiner distance in graphs. For a nonempty vertex set S ⊆ V ( G ) , its Steiner distance d G ( S ) is the minimum number of edges in a connected subgraph of G containing S. Clearly, if S = { u , v } , then d G ( S ) = d G ( u , v ) . Dankelmann et al. [6] subsequently investigated the average Steiner distance, establishing fundamental bounds and relationships between Steiner distances of different orders. Li et al. [7] introduced the Steiner k-Wiener index,
S W k ( G ) = ∑ S ⊆ V ( G ) , | S | = k d G ( S ) ,
which generalizes the classical Wiener index, since S W 2 ( G ) = W ( G ) . These developments provide a systematic framework for studying multi-vertex distance parameters and their extremal properties.
Another natural approach to three-vertex distance arises from the classical Fermat–Torricelli problem, which seeks a point minimizing the sum of its distances to three given points. In graph theory, this problem is closely related to median and network-location problems, whose early development includes the work of Hakimi [8]. For vertices x , y , z ∈ V ( G ) , the Fermat distance is defined by
F G ( x , y , z ) = min p ∈ V ( G ) { d G ( p , x ) + d G ( p , y ) + d G ( p , z ) } .
For three terminals, the Fermat distance coincides with the Steiner distance d G ( x , y , z ) . Consequently, the average Fermat distance satisfies
F ¯ ( G ) = 1 n 3 S W 3 ( G ) .
Thus, although motivated by a different geometric interpretation, average Fermat distance is closely connected to the theory of Steiner–Wiener indices. Explicit calculations of average Fermat distances have also attracted attention in the study of fractal and hierarchical networks. For instance, Jia et al. [9] studied Vicsek networks, and Peng et al. [10] investigated a class of hierarchical scale-free networks.
The relationship between three-point Fermat distance and ordinary pairwise distances leads to a further graph invariant. By the triangle inequality, for any three vertices x , y , z ,
F G ( x , y , z ) ≥ 1 2 d G ( x , y ) + d G ( y , z ) + d G ( z , x ) .
The difference between these quantities is called the Fermat difference:
Δ G ( x , y , z ) = F G ( x , y , z ) − 1 2 d G ( x , y ) + d G ( y , z ) + d G ( z , x ) .
For convenience, we sometimes omit the subscripts in F G and Δ G and simply write F and Δ .
Fermat difference statistics were explicitly investigated by Peng et al. [11] in the context of complex networks, with particular emphasis on their topological significance. For a connected graph G of order n, the average Fermat difference is defined as
Δ ¯ ( G ) = 1 n 3 ∑ { x , y , z } ⊆ V ( G ) Δ G ( x , y , z ) .
Since each unordered vertex pair belongs to exactly n − 2 distinct triples, we have
Δ ¯ ( G ) = S W 3 ( G ) − n − 2 2 W ( G ) n 3 .
This identity reveals a direct connection between Fermat difference, the Wiener index and the Steiner 3-Wiener index. In particular, Kovše et al. [12] established the corresponding inequality between the latter two indices and characterized its equality case in terms of modular graphs. Hence Δ ¯ ( G ) ≥ 0 , with equality precisely when every vertex triple admits a common median. In this sense, Fermat difference measures the extent to which three-point distances fail to admit a common shortest-path decomposition. Consequently, its extremal behavior depends on the interplay between these two distance indices, rather than on either index separately. Understanding this interplay may reveal structural properties that are not captured by the extremal analysis of the individual indices.
Unicyclic graphs provide a particularly suitable setting for this investigation. Each such graph consists of a unique cycle with trees attached to its vertices. This structure allows us to separate the cyclic contribution from the attached trees while retaining the essential features of three-vertex distances. Previous studies have examined Fermat-difference statistics in complex networks [11] and extremal distance indices, including the Wiener index and the Steiner k-Wiener index, on unicyclic graphs [13,14,15,16]. However, these results do not directly determine the extremal behavior of the average Fermat difference for unicyclic graphs of prescribed order and cycle length.
In this paper, we address this problem by developing a projection method that reduces the average Fermat difference to a weighted cubic expression on the unique cycle. This reduction enables us to investigate three related questions: the exact evaluation for cycles, the minimum average Fermat difference and its equality cases for prescribed order and cycle length, and upper bounds under the same constraints. We further determine the maximum average Fermat difference among all unicyclic graphs of a given order and characterize the corresponding extremal graphs. These results provide a systematic approach to the extremal analysis of this distance invariant and clarify how cycle length and the distribution of attached trees influence its value.
The remainder of the paper is organized as follows. Section 1 establishes basic formulas for cycles. Section 2 develops the projection method and derives the weighted-cycle representation. Section 3 determines the sharp lower bound and characterizes its equality cases. Section 4 establishes upper bounds and proves the extremal result for unicyclic graphs of fixed order.

2. Fermat Difference on m -Cycle

Let C m be a cycle with length m. Denote a + = max { a , 0 } , where a ∈ R .
Theorem 1.
Suppose that x, y, z are distinct vertices of C m that cut C m into three paths of lengths a, b and c. Let M = max { a , b , c } . Then,
F ( x , y , z ) = m − M
and
Δ ( x , y , z ) = m 2 − M + .
Proof. 
The Fermat distance equals the Steiner distance for three terminals. A minimum connected subgraph of C m containing x , y , z is obtained by deleting the edges of a longest gap. Hence F ( x , y , z ) = m − M . If M ≤ m / 2 , then
d ( x , y ) + d ( y , z ) + d ( z , x ) = a + b + c = m .
If M ≥ m / 2 , then
d ( x , y ) + d ( y , z ) + d ( z , x ) = 2 ( m − M ) .
Consequently,
Δ ( x , y , z ) = m − M − 1 2 d ( x , y ) + d ( y , z ) + d ( z , x ) = m 2 − M + .
□
Corollary 1.
We have d m * : = Δ max ( C m ) = m 2 − ⌈ m 3 ⌉ + .
The total Fermat difference of G is given by
S ( G ) = S W 3 ( G ) − n − 2 2 W ( G ) = ∑ { x , y , z } ⊂ V ( G ) Δ ( x , y , z ) .
We then have
s m : = S ( C m ) = m 3 ∑ a + b + c = m m 2 − M + .
The factor m 3 arises because each unordered triple is counted exactly three times when summing over all starting vertices of the cycle.
Lemma 1.
Let L = ⌈ m 3 ⌉ and U = ⌊ m − 1 2 ⌋ . We obtain
s m = m 3 1 { 3 ∣ m } m 6 + ∑ k = L U m 2 − k ( 9 k − 3 m ) .
Proof. 
Notice that only ordered triples ( a , b , c ) with L ≤ M = max { a , b , c } ≤ U contribute to s m . For each L ≤ k ≤ U , let N m ( k ) be the number of ordered positive integer triples satisfying a + b + c = m and M = k . If a = k , then b + c = m − k and m − 2 k ≤ b ≤ k , giving 3 k − m + 1 choices. By symmetry and inclusion–exclusion,
N m ( k ) = 3 ( 3 k − m + 1 ) − 3 + 1 { m = 3 k } = 9 k − 3 m + 1 { m = 3 k } .
Here, the last term accounts for the triple ( k , k , k ) when m = 3 k . Consequently,
s m = m 3 ∑ k = L U m 2 − k N m ( k ) = m 3 1 { 3 ∣ m } m 6 + ∑ k = L U m 2 − k ( 9 k − 3 m ) ,
which gives Equation (1). □
Theorem 2.
For m ≥ 3 , the total sum of Fermat difference of C m is
s m = m 4 + α m m 2 + β m m 432 ,
where
α m = 15 , m odd , − 12 , m even , β m = 0 , m ≡ 0 ( mod 3 ) , − 16 , m ≡ 1 ( mod 3 ) , 16 , m ≡ 2 ( mod 3 ) .
Proof. 
Suppose that m = 6 q + r , 0 ≤ r ≤ 5 . We have L = 2 q + ⌈ r 3 ⌉ , U = 3 q + ⌊ r − 1 2 ⌋ . Now from Equation (1), we get the conclusion. □
We list the closed form of s m below; see Table 1.
Table 1. The closed form of s m and Δ ¯ ( C m ) .
From Table 1, we immediately obtain the asymptotic formulas as m → ∞ :
s m m 4 → 1 432 , Δ ¯ ( C m ) m → 1 72 , Δ ¯ ( C m ) d m * → 1 12 .

3. Projection on Unicyclic Graph

Let U ( n , m ) be the collection of unicyclic graphs with n vertices and exactly one cycle of length m. For G ∈ U ( n , m ) , denote the unique cycle C m by v 0 v 1 ⋯ v m − 1 . If we delete all edges of C m , then we get m subtrees T i with root v i , i = 0 , 1 , … , m − 1 . Let
ω i = | V ( T i ) | ≥ 1 , ∑ i = 0 m − 1 ω i = n .
For a vertex x ∈ T i , set the projection of x on C m as pro ( x ) = v i .
Theorem 3.
For an arbitrary vertex triple ( x , y , z ) in G ∈ U ( n , m ) , we have
Δ G ( x , y , z ) = Δ C m ( pro ( x ) , pro ( y ) , pro ( z ) ) .
Clearly, the Fermat difference equals 0 whenever two vertices share the same projection.
Proof. 
For x, y, z ∈ T i , it is immediate that Δ G ( x , y , z ) = Δ T i ( x , y , z ) = 0 = Δ C m ( pro ( x ) , pro ( y ) , pro ( z ) ) .
For x, y ∈ T i and z ∈ T j , i ≠ j , we have
F ( x , y , z ) = F ( x , y , v i ) + d ( v i , v j ) + d ( v j , z ) = 1 2 d ( x , v i ) + d ( y , v i ) + d ( x , y ) + d ( v i , v j ) + d ( v j , z ) = 1 2 d ( x , y ) + d ( y , z ) + d ( z , x ) ,
which implies that Δ G ( x , y , z ) = 0 = Δ C m ( pro ( x ) , pro ( y ) , pro ( z ) ) .
We now suppose that x, y, z belong to distinct subtrees T i , T j , T k , respectively. Notice that pro ( x ) = v i , pro ( y ) = v j , pro ( z ) = v k . It follows that
F ( x , y , z ) = d ( x , v i ) + d ( y , v j ) + d ( z , v k ) + F ( v i , v j , v k ) = 1 2 d ( x , y ) + d ( y , z ) + d ( z , x ) + F ( v i , v j , v k ) − 1 2 d ( v i , v j ) + d ( v j , v k ) + d ( v k , v i ) .
Hence Δ G ( x , y , z ) = Δ C m ( v i , v j , v k ) = Δ C m ( pro ( x ) , pro ( y ) , pro ( z ) ) . □
From Theorem 3, we can reduce the problem to a weighted cycle ω ( v i ) = ω i . Now for 0 ≤ i < j < k < m , let δ i j k = m 2 − max { j − i , k − j , m − k + i } + . There are ω i ω j ω k ways to select one vertex from each of the three attached subtrees T i , T j , T k . We get the following.
Theorem 4.
The total Fermat difference of unicyclic graph G is given by
S ( G ) = ∑ 0 ≤ i < j < k < m δ i j k ω i ω j ω k .

4. Sharp Lower Bounds for Unicyclic Graphs

The projection formula established in Section 2 reduces the original problem to a weighted cycle. We now determine the sharp lower bound for the average Fermat difference and characterize all extremal graphs attaining equality.
Let t = n − m , ω i = 1 + t i , t i ≥ 0 . We have ∑ i = 0 m − 1 t i = t . Hence Equation (3) can be expanded to yield
S ( G ) = ∑ 0 ≤ i < j < k < m δ i j k ( 1 + t i ) ( 1 + t j ) ( 1 + t k ) = s m + 3 s m m t + ∑ 0 ≤ i < j < m B i j t i t j + ∑ 0 ≤ i < j < k < m δ i j k t i t j t k ,
where B i j = ∑ k ∉ { i , j } δ { i , j , k } is the coefficient of the quadratic terms. Here, δ { i , j , k } differs from δ i j k ; the order of indices is not required.
We now give the sharp lower bound of G ∈ U ( n , m ) .
Theorem 5.
Fix m. For 3 ≤ m ≤ n , we have
S ( G ) ≥ 3 n − 2 m m s m ,
and thus
Δ ¯ ( G ) ≥ 1 n 3 3 n − 2 m m s m .
The lower bounds are sharp and can be achieved if at most one of the rooted trees T i is nontrivial.
Proof. 
The last two terms of Equation (4) are non-negative. By symmetry, we choose t 0 = t , t 1 = ⋯ = t m − 1 = 0 to minimize the last two terms. So the lower bound of S ( G ) is s m + 3 s m m t = 3 n − 2 m m s m and the corresponding graphs are formed by attaching a tree with n − m + 1 vertices by one of its vertices to C m . □
Corollary 2.
For n ≥ 4 , we have
min m min G ∈ U ( n , m ) S ( G ) = 0 ,
and thus
min m min G ∈ U ( n , m ) Δ ¯ ( G ) = 0 .
The minimum is attained if and only if m = 4 .
Proof. 
By expression of s m = 0 , it follows s m = 0 if and only if m = 4 . So the lower bound of Equation (4) is 0. □
Remark 1.
From the corollary, the minimal constructions of graphs in Theorem 5 are not unique.
Remark 2.
The unicyclic graph with cycle length 4 is a modular graph; see [12].
Set A = { i : t i > 0 } .
Theorem 6.
G ∈ U ( n , m ) reaches the lower bound min U ( n , m ) Δ ¯ ( G ) if and only if one of the following conditions holds:
1. 
m is odd and | A | ≤ 1 ;
2. 
m ≥ 6 is even and | A | ≤ 2 . If | A | = 2 , then A = { i , i + 1 ( mod m ) } or { i , i + m 2 ( mod m ) } ;
3. 
m = 4 .
Proof. 
By Equation (4), the lower bound is attained if and only if B i j = 0 for all distinct i, j ∈ A . Indeed, all quadratic and cubic terms are non-negative. Moreover, if i , j , k ∈ A and δ i j k > 0 , then B i j ≥ δ i j k > 0 . By the symmetry of C m , we may assume that any pair of distinct roots can be mapped to 0, d, where 1 ≤ d ≤ ⌊ m 2 ⌋ .
  • Suppose first that m = 2 h + 1 . Taking the third root to be h + 1 , the three gaps are d, h + 1 − d , h. All of them are smaller than m 2 , so Theorem 1 gives δ { 0 , d , h + 1 } > 0 . Consequently, B 0 d > 0 for every d, and equality holds if and only if | A | ≤ 1 .
  • Now suppose that m = 2 h ≥ 6 . If d = 1 , any third root k ∈ { 2 , … , 2 h − 1 } gives gaps 1, k − 1 , 2 h − k . The last two gaps sum to 2 h − 1 , so at least one is at least h. Hence every such triple has zero Fermat difference. If d = h , the roots 0 , h are antipodal. Any third root splits one of the two semicircles, leaving the other gap equal to h, so B 0 h = 0 . For 2 ≤ d ≤ h − 1 , choose the third root h + 1 . The resulting gaps are d, h + 1 − d , h − 1 , all strictly smaller than h. Thus δ { 0 , d , h + 1 } > 0 and B 0 d > 0 . We have therefore shown that B i j = 0 precisely when the two roots are adjacent or antipodal.
    It remains to show that A cannot contain three roots satisfying this pairwise condition. If 0 ∈ A , every other element of A must belong to { 1 , 2 h − 1 , h } . The distances between distinct members of this set are 2 or h − 1 , neither of which equals 1 or h for h ≥ 3 . Hence | A | ≤ 2 . When | A | = 2 , equality holds precisely when the two roots are adjacent or antipodal.
  • If m = 4 , every triple of distinct cycle vertices has gaps 1 , 1 , 2 , so δ i j k = 0 for all triples. Thus every graph in U ( n , 4 ) attains the lower bound 0; also see Corollary 2.
We now complete the proof. □

5. Upper Bounds for Unicyclic Graphs

We next turn to the maximization problem, which requires a more detailed analysis of the interactions among the attached trees. We first derive an upper bound for prescribed order and cycle length, and then determine the sharp maximum over all unicyclic graphs of fixed order.
Lemma 2.
Let b m * = max i < j B i j . We have
b m * = ⌊ m 2 32 ⌋ , m even , 1 2 ⌊ m 2 + 7 16 ⌋ , m odd .
Proof. 
By symmetry, we only consider B 0 d , 1 ≤ d ≤ ⌊ m 2 ⌋ . When m = 2 h ,
B 0 d = ∑ r = 1 d − 1 min { r , d − r , h − d } .
If h − d ≥ d 2 , then we have B 0 d = ∑ r = 1 d − 1 min { r , d − r } = ⌊ d 2 4 ⌋ .
If h − d ≤ d 2 , then we have
min { r , d − r , h − d } = r , 1 ≤ r ≤ h − d − 1 , h − d , h − d ≤ r ≤ d − ( h − d ) , d − r , d − ( h − d ) + 1 ≤ r ≤ d − 1 .
Hence
B 0 d = ∑ r min { r , d − r , h − d } = ( h − d ) ( 2 d − h ) .
Here, B 0 d = h 2 8 − 2 d − 3 4 h 2 implies b m * = ⌊ h 2 8 ⌋ = ⌊ m 2 32 ⌋ ≥ ⌊ d 2 4 ⌋ for d ≤ 2 h 3 . It follows that b m * = ⌊ m 2 32 ⌋ .
Similarly,
B 0 d = ∑ r = 1 d min { r − 1 2 , d − r + 1 2 , h − d + 1 2 }
if m = 2 h + 1 .
We then have
B 0 d = d 2 + ⌊ ( d − 1 ) 2 4 ⌋ − ⌊ ( 3 d − 2 h − 1 ) + 4 ⌋ , h − d + 1 2 ≥ d 2 m 2 + 8 32 − 2 d − 3 m 8 2 , h − d + 1 2 ≤ d 2 .
Hence b m * = 1 2 ⌊ m 2 + 7 16 ⌋ if m = 2 h + 1 . □
Lemma 3.
∑ 0 ≤ i < j < m B i j t i t j ≤ b m * t 2 3 .
Proof. 
If m = 4 , then B i j = 0 for all distinct i , j , and the assertion is immediate. Hence assume that m ≠ 4 .
Identify the cycle with R / m Z and put q = m 3 . Choose s uniformly from [ 0 , q ) and define
I a ( s ) = [ s + a q , s + ( a + 1 ) q ) ( mod m ) , a = 0 , 1 , 2 .
Let
L a ( s ) = ∑ i = 0 m − 1 t i 1 { i ∈ I a ( s ) } .
Then L 0 , L 1 , L 2 are non-negative integers satisfying L 0 + L 1 + L 2 = t .
For distinct roots i , j , let χ i j ( s ) indicate whether they belong to different arcs. For every s, we have
L 0 L 1 + L 1 L 2 + L 2 L 0 = ∑ 0 ≤ i < j < m t i t j χ i j ( s ) .
Write d i j for the shortest path distance between i and j on C m . The separation probability depends only on this distance; denote it by p ( d ) . If d < q , the roots are separated precisely when a partition boundary falls on the shorter arc between them, which occurs with probability d / q . If d ≥ q , the roots cannot belong to the same half-open arc of length q. Therefore,
p ( d ) = min 1 , 3 d m .
We next show that
B 0 d ≤ b m * p ( d ) , 1 ≤ d ≤ m 2 .
For d ≥ m 3 , this follows from the definition of b m * . Suppose that d < m 3 . The formulas in the proof of Lemma 2 give
B 0 d ≤ d 2 4 , m even , d 2 + 1 4 , m odd .
If m ≥ 12 is even, then
b m * = m 2 32 ≥ m 2 − 16 32 ≥ m 2 36 ,
where the first inequality follows from m 2 ≡ 0 , 4 , 16 ( mod 32 ) . Hence
B 0 d ≤ d 2 4 ≤ m d 12 ≤ 3 d m b m * .
If m ≥ 9 is odd, then
b m * = 1 2 m 2 + 7 16 ≥ m 2 − 1 32 ,
since m 2 ≡ 1 , 9 ( mod 16 ) . As x + x − 1 is non-decreasing for x ≥ 1 , we obtain
B 0 d d ≤ 1 4 d + 1 d ≤ m 2 + 9 12 m ≤ 3 ( m 2 − 1 ) 32 m ≤ 3 b m * m .
The penultimate inequality is equivalent to m 2 ≥ 81 .
For m = 3 , there is no positive integer d < m 3 . For the remaining values of m, direct substitution into the formulas for B 0 d gives
m   5   6     7     8     10
max 1 ≤ d < m / 3 B 0 d d 3 b m * m 1 2 0 1 2 1 2 2 3 3 5 1 2 9 14 3 4 9 10
and the desired inequality holds in each case. By symmetry, we conclude that B i j ≤ b m * p ( d i j ) for all distinct i , j .
Taking expectations in the identity above yields
∑ 0 ≤ i < j < m B i j t i t j ≤ b m * ∑ 0 ≤ i < j < m t i t j p ( d i j ) = b m * E ( L 0 L 1 + L 1 L 2 + L 2 L 0 ) .
Finally, for every s,
L 0 L 1 + L 1 L 2 + L 2 L 0 = t 2 − ( L 0 2 + L 1 2 + L 2 2 ) 2 ≤ t 2 3 .
Since the left-hand side is an integer, it is at most ⌊ t 2 3 ⌋ . Consequently,
∑ 0 ≤ i < j < m B i j t i t j ≤ b m * t 2 3 ,
as required. □
A tournament is a directed graph obtained by assigning a direction to each edge of a complete graph. Thus, for every pair of distinct vertices u and v, exactly one of the arcs u → v and v → u is present. Every three vertices induce either a transitive tournament or a directed 3-cycle.
Lemma 4.
For a tournament with t vertices ( t ≥ 3 ), the number of directed 3-cycle is at most
τ ( t ) = t 3 − t 24 , t odd , t 3 − 4 t 24 , t even .
For convenience, set τ ( 0 ) = τ ( 1 ) = τ ( 2 ) = 0 .
Proof. 
Suppose that out-degree of vertex i is a i . In each transitive triple, exactly one vertex dominates the other two, so the number of directed triangles equals
t 3 − ∑ i = 1 t a i 2 .
Notice that ∑ i = 1 t a i = t ( t − 1 ) 2 . Convexity implies that the last term in Equation (6) is minimized when the out-degrees are as equal as possible. When t is odd, all a i equal t − 1 2 . When t is even, there are t 2 copies of t 2 and t 2 copies of t 2 − 1 . Substituting these yields the upper bound. □
Lemma 5.
The cubic term of S ( G ) satisfies
∑ i < j < k δ i j k t i t j t k ≤ d m * τ ( n − m ) .
Proof. 
Construct a tournament on the t = n − m vertices outside the cycle. Given two vertices x and y, if their projections are neither coincident nor antipodal, orient them along the clockwise arc shorter than half the cycle; assign arbitrary orientations to all other vertex pairs. When a triple produces a positive Fermat difference, each of the three arcs has length less than half the cycle; hence these three extra vertices form a directed triangle. By Lemma 4 and the definition of d m * , we get
∑ i < j < k δ i j k t i t j t k ≤ d m * τ ( n − m ) ,
as desired. □
Lemma 6.
Let p s e p ( i , j , k ) be the probability that three roots i, j, k belong to three different arcs. We then have
δ i j k ≤ m 6 p s e p ( i , j , k ) .
Consequently, ∑ i < j < k δ i j k t i t j t k ≤ m 6 ⌊ t 3 ⌋ ⌊ t + 1 3 ⌋ ⌊ t + 2 3 ⌋ .
Proof. 
Put q = m 3 , and let a, b, c be the three consecutive gaps determined by the roots, with M = max { a , b , c } . If M ≥ m 2 , then δ i j k = 0 , and the assertion is immediate. Hence assume that M < 3 q 2 .
The three roots cannot lie in one arc of length q, since this would leave a gap of at least 2 q , contradicting M < 3 q 2 . Consequently, the events that a specified pair lies in the same arc are mutually disjoint. For a consecutive gap a < q , the corresponding pair lies in the same arc with probability 1 − a q ; a gap of at least q contributes no such event.
If a = b = c = q , then p sep ( i , j , k ) = 1 and δ i j k = q 2 . If exactly one gap, say a, is smaller than q, then
p sep ( i , j , k ) = a q , M ≥ b + c 2 = 3 q − a 2 .
It follows that
δ i j k = 3 q 2 − M ≤ a 2 = q 2 p sep ( i , j , k ) .
If exactly two gaps, say a , b , are smaller than q, then c = M > q . By the mutual disjointness noted above,
p sep ( i , j , k ) = 1 − 1 − a q − 1 − b q = 2 q − M q .
Thus
δ i j k = 3 q 2 − M ≤ q − M 2 = q 2 p sep ( i , j , k ) .
These cases exhaust all possibilities, proving
δ i j k ≤ m 6 p sep ( i , j , k ) .
Using the random arcs and masses defined in the proof of Lemma 3, we have
L 0 L 1 L 2 = ∑ i < j < k t i t j t k 1 { i , j , k lie in distinct arcs } .
Taking expectations therefore gives
∑ i < j < k δ i j k t i t j t k ≤ m 6 ∑ i < j < k t i t j t k p sep ( i , j , k ) = m 6 E ( L 0 L 1 L 2 ) .
Since L 0 , L 1 , L 2 are non-negative integers with L 0 + L 1 + L 2 = t , their product is maximized when they differ by at most 1. Hence
∑ i < j < k δ i j k t i t j t k ≤ m 6 t 3 t + 1 3 t + 2 3 ,
and the proof is complete. □
Set P ( t ) = ⌊ t 3 ⌋ ⌊ t + 1 3 ⌋ ⌊ t + 2 3 ⌋ .
Theorem 7.
We have
S ( G ) ≤ 3 n − 2 m m s m + b m * ⌊ t 2 3 ⌋ + min d m * τ ( t ) , m 6 P ( t )
and
Δ ¯ ( G ) ≤ 1 n 3 3 n − 2 m m s m + b m * ⌊ t 2 3 ⌋ + min d m * τ ( t ) , m 6 P ( t ) ,
where t = n − m .
Proof. 
From Lemmas 2, 3, 5 and 6, we straightforwardly derive the upper bound of S ( G ) and Δ ¯ ( G ) . □
Remark 3.
The upper bounds in Theorem 7 may not be sharp, since the last two terms of the upper bound of S ( G ) may not be achieved at the same time.
We now give the global extremal value of unicyclic graph G with given n vertices. Set U n = ∪ m = 3 n U ( n , m ) .
Theorem 8.
For n ≥ 4 , Let H n be obtained from C n − 1 by attaching a pendant edge to one of its vertices. For n ≥ 3 ,
max G ∈ U n Δ ¯ ( G ) = 1 n 3 s n , n odd or n ≥ 26 , n + 2 n − 1 s n − 1 , n even and 4 ≤ n ≤ 24 .
In the first case C n is the unique maximizing graph. In the second case H n is unique except for two additional cases: at n = 6 , a triangle with a leaf at each root; at n = 8 , a pentagon with a leaf at each of three roots having gaps 1, 2, 2.
Proof. 
Suppose that t = n − m ≥ 1 and n ≥ 26 . Notice that s m ≤ m 4 + 15 m 2 + 16 m 432 , b m * ≤ m 2 + 7 32 , d m * ≤ m 6 , τ ( t ) ≤ t 3 − t 24 . Taking a weaker estimate
∑ 0 ≤ i < j < m B i j t i t j ≤ b m * t 2 ,
we have an upper bound
S ( G ) ≤ m 4 + 15 m 2 + 16 m 432 1 + 3 t m + ( m 2 + 7 ) ( t 2 − t ) 64 + m ( t 3 − t ) 144 .
We also have
s n ≥ n 4 − 12 n 2 − 16 n 432 .
Subtract the right-hand side of (9) from that of (10) and multiply the result by 1728 to obtain
P ( m , t ) = 4 t m 3 − 3 t 2 m 2 + 4 t 3 m + 4 t 4 + 27 ( t − 4 ) m 2 − 264 t m − 237 t 2 − 128 m − 67 t .
We need to verify P ( m , t ) ≥ 0 .
  • t ≥ 11 . Notice that m ≥ 3 . It is clear that
    4 t m 3 − 3 t 2 m 2 + 4 t 3 m = 5 2 m t ( m 2 + t 2 ) + 3 2 m t ( m − t ) 2 ≥ 325 m t .
    We thus have
    P ( m , t ) ≥ 325 m t + 4 t 4 + 27 ( t − 4 ) m 2 − 264 t m − 237 t 2 − 128 m − 67 t = ( 4 t 4 − 237 t 2 − 67 t ) + m ( 61 t − 128 ) + 27 ( t − 4 ) m 2 > 0 .
  • 1 ≤ t ≤ 10 . Set u = m + t − 26 , u ≥ 0 . We have
    P ( m , t ) = 4 t u 3 + ( − 15 t 2 + 339 t − 108 ) u 2 + ( 22 t 3 − 834 t 2 + 9468 t − 5744 ) u + ( t − 1 ) ( 76336 − 11033 t + 592 t 2 − 7 t 3 ) ≥ 0
    for 1 ≤ t ≤ 10 . Here, P ( m , t ) = 0 if and only if ( t , u ) = ( 1 , 0 ) , which implies ( n , m ) = ( 26 , 25 ) . However, (10) holds strictly for n = 26 . So for 3 ≤ m < n and n ≥ 26 , S ( G ) < s n implies
    max G ∈ U n Δ ¯ ( G ) = 1 n 3 S ( C n ) = 1 n 3 s n .
We now check n ≤ 25 . By computing the upper bounds of Δ ¯ ( G ) for n − m ≥ 2 in Theorem 7 one by one and comparing them with the target values in Theorem 8, we obtain Table 2.
Table 2. Results for small n.
In Table 2, we observe that when m = n , the unique extremal graph C n is attained; when m = n − 1 , the unique extremal graph H n is attained; when ( n , m ) = ( 6 , 3 ) , the graph is a triangle with a leaf at each root, and for ( n , m ) = ( 8 , 5 ) , verification yields a pentagon with a leaf at each of three roots having gaps 1, 2, 2. □

6. Concluding Remarks

In this paper, we investigated the average Fermat difference of unicyclic graphs. By reducing the problem to a weighted cycle, we obtained an exact formula for cycles and established a sharp lower bound with a characterization of the corresponding extremal graphs. We also derived an upper bound for unicyclic graphs with prescribed order and cycle length, and determined the sharp upper bound among all unicyclic graphs of fixed order. These results reveal the role of cycle length and the distribution of attached trees in determining the average Fermat difference. Determining the exact upper bound for every prescribed cycle length and extending these results to bicyclic and more general graph classes remain interesting problems for further investigation.

Author Contributions

C.Z.: Conceptualization; methodology; formal analysis; writing—original draft. D.W.: Writing—review and editing; supervision; funding acquisition. All authors have read and agreed to the published version of the manuscript.

Funding

This work was partially supported by the National Natural Science Foundation of China (No. 12301107) and the Shandong Provincial Natural Science Foundation, China (No. ZR202209010046).

Data Availability Statement

Dataset available on request from the authors.

Acknowledgments

The authors declare that artificial intelligence (AI) was only used to improve readability of the manuscript text, assist with LaTeX formatting, verify the proof, and produce verification code for the case n ≤ 25 in Theorem 8. AI was not used to design the research, produce mathematical arguments. All authors reviewed the manuscript and accepted accountability for the work.

Conflicts of Interest

The authors declare no conflicts of interest.

References

  1. Wiener, H. Structural determination of paraffin boiling points. J. Am. Chem. Soc. 1947, 69, 17–20. [Google Scholar] [CrossRef] [Scilit] [PubMed]
  2. Watts, D.J.; Strogatz, S.H. Collective dynamics of small-world networks. Nature 1998, 393, 440–442. [Google Scholar] [CrossRef] [Scilit] [PubMed]
  3. Newman, M.E.J. The structure and function of complex networks. SIAM Rev. 2003, 45, 167–256. [Google Scholar] [CrossRef] [Scilit]
  4. Wang, S.; Yu, Z.; Xi, L. Average geodesic distance of Sierpiński gasket and Sierpiński networks. Fractals 2017, 25, 1750044. [Google Scholar] [CrossRef] [Scilit]
  5. Chartrand, G.; Oellermann, O.R.; Tian, S.L.; Zou, H.B. Steiner distance in graphs. Časopis Pěst. Mat. 1989, 114, 399–410. [Google Scholar] [CrossRef] [Scilit]
  6. Dankelmann, P.; Oellermann, O.R.; Swart, H.C. The average Steiner distance of a graph. J. Graph Theory 1996, 22, 15–22. [Google Scholar] [CrossRef] [Scilit]
  7. Li, X.; Mao, Y.; Gutman, I. The Steiner Wiener index of a graph. Discuss. Math. Graph Theory 2016, 36, 455–465. [Google Scholar] [CrossRef] [Scilit]
  8. Hakimi, S.L. Optimum locations of switching centers and the absolute centers and medians of a graph. Oper. Res. 1964, 12, 450–459. [Google Scholar] [CrossRef] [Scilit]
  9. Jia, Q.; Lei, L.; Xi, L. Average Fermat distances on Vicsek networks. Fractals 2021, 29, 2150249. [Google Scholar] [CrossRef] [Scilit]
  10. Peng, L.; Zeng, C.; Chen, D.; Xue, Y.; Zhao, Z. Average Fermat distance of a pseudo-fractal hierarchical scale-free network. Fractals 2023, 31, 2350013. [Google Scholar] [CrossRef] [Scilit]
  11. Peng, L.; Wang, D.; Xue, Y.; Zeng, C.; He, H. Empirical studies and topological implications of Fermat difference statistics for complex networks. Chaos Soliton Fract. 2026, 202, 117449. [Google Scholar] [CrossRef] [Scilit]
  12. Kovše, M.; Rasila, V.A.; Vijayakumar, A. Wiener index and Steiner 3-Wiener index of a graph. Asian-Eur. J. Math. 2021, 14, 2150165. [Google Scholar] [CrossRef] [Scilit]
  13. Yu, G.H.; Feng, L.H. On the Wiener index of unicyclic graphs with given girth. Ars. Comb. 2010, 94, 361–369. [Google Scholar]
  14. Ilić, A.; Stevanović, D.; Feng, L.H.; Yu, G.H.; Dankelmann, P. Degree distance of unicyclic and bicyclic graphs. Discret. Appl. Math. 2011, 159, 779–788. [Google Scholar] [CrossRef] [Scilit]
  15. Fan, J.Q.; Zhao, B. On the Extremal Steiner Wiener Index of Unicyclic Graphs. MATCH Commun. Math. Comput. Chem. 2022, 88, 205–218. [Google Scholar] [CrossRef] [Scilit]
  16. Zhang, J.; Ji, Y. Extremal problems for Steiner Wiener index of unicyclic graphs. Oper. Res. Trans. 2023, 27, 178–184. [Google Scholar]
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.

Article Metrics

Citations

Article Access Statistics

Multiple requests from the same IP address are counted as one view.