Next Article in Journal
Numerical Solutions for Fractional Fixation Times in Evolutionary Models
Previous Article in Journal
The Classical Origin of Spin: Vectors Versus Bivectors
Previous Article in Special Issue
Neighbor Full Sum Distinguishing Total Coloring of Planar Graphs with Girth at Least 5
 
 
Font Type:
Arial Georgia Verdana
Font Size:
Aa Aa Aa
Line Spacing:
Column Width:
Background:
Article

On Structural Characterization and Computation of the Diameter and Girth of Bipartite Gap Poset Graphs with Python Application

1
Department of Mathematics, Government College University, Faisalabad 38000, Pakistan
2
Department of Mathematical Sciences, College of Science, Princess Nourah Bint Abdulrahman University, P.O. Box 84428, Riyadh 11671, Saudi Arabia
3
Department of Mathematics, College of Science, Sultan Qaboos University, P.O. Box 36, Muscat 123, Oman
*
Author to whom correspondence should be addressed.
Axioms 2025, 14(9), 669; https://doi.org/10.3390/axioms14090669
Submission received: 25 July 2025 / Revised: 23 August 2025 / Accepted: 26 August 2025 / Published: 29 August 2025
(This article belongs to the Special Issue Graph Invariants and Their Applications)

Abstract

In this article, a correspondence between some important classes of numerical semigroups and well-known families of bipartite graphs has been established. Also, it has been demonstrated that, if m ( S ) is the multiplicity of a numerical semigroup S , then the diameter and the girth of bipartite gap poset graphs are bounded by the numbers 2 m ( S ) 3 and m ( S ) 1 , respectively. Moreover, the Python code to compute the diameter and girth of gap poset graphs has been implemented.

1. Introduction and Preliminaries

Algebraic graph theory is an interrelated research field that explores the fundamental relationships between algebra and graph theory [1,2]. It focuses on how algebraic structures such as groups, rings, and semigroups can be viewed and explored by using graphs, allowing graph-theoretic methods to expose algebraic aspects and vice versa. In 1878, Cayley [3] laid the foundation of this field by introducing Cayley graphs to represent groups graphically, offering visual and structural insight into group operations and symmetries. Later, in 1988, Beck [4] made a significant contribution to this field by introducing the concept of zero-divisor graphs for commutative rings. In this construction, the vertex set consists of non-zero zero-divisors of the ring, and two unique members are neighboring if their product is zero. This graphical form has been effective for understanding ring-theoretic characteristics like annihilators, ideals, and prime elements. Following Beck’s work, numerous authors expanded and generalized this concept. Anderson and Livingston [5] developed the zero-divisor graph by focusing primarily on non-zero zero-divisors, while Anderson and Badawi [6,7] investigated modifications such as entire graphs and ideal-based graphs, providing more information about the structure of commutative rings. Recently, different mathematicians [8,9,10,11,12] have assigned graphs to numerical semigroups and studied some properties of the graphs.
Graphs are widely used across numerous disciplines, including computer science, biology, communication networks, and operations research, due to their ability to abstractly represent complex systems, such as transportation routes, social interactions, molecular structures, and data networks [13,14]. In particular, bipartite graphs based on algebraic concepts are important for expressing interactions in chemical reaction networks and metabolic pathways [15]. This collaboration not only enriches the theoretical foundations of both fields but also helps to solve real-world problems using a combined algebraic-combinatorial perspective.
A graph G = ( V , E ) consists of a finite set of vertices V and a set of edges E, where each edge connects a pair of vertices. The neighborhood of a vertex v in a simple undirected graph G = ( V , E ) , denoted by N ( v ) , is the set of all the vertices adjacent to v, and its cardinality is known as a degree of v, denoted by d e g ( v ) . The diameter of a graph is the greatest distance between any pair of vertices in the graph, denoted by d i a m ( G ) . A cycle is a closed path with no repeated edges or internal vertices, and the girth of a graph is defined as the length of its shortest cycle, represented by g r ( G ) . A path graph P n is a simple linear graph where each internal vertex is adjacent to exactly two others, and the endpoints have a degree 1. A graph K n is said to be complete if every pair of distinct vertices is joined by an edge. A bipartite graph B G admits a vertex partition into two disjoint sets such that all the edges connect vertices across the sets, with no edges within a set. It is said to be balanced if both parts have equal cardinality. A regular graph is one in which all the vertices have the same degree, reflecting a uniform local structure.
In algebraic and applied contexts, graph invariants such as diameter and girth play pivotal roles in understanding both abstract structure and practical behavior. Within the algebraic framework of numerical semigroups, a small diameter in the associated gap poset graph reflects tightly interrelated gaps, often corresponding to semigroups with smaller multiplicity or denser Apéry sets. It is a property that directly relates to efficiency and robustness in real-world networks. For example, in communication networks, diameter is used to evaluate the Diameter-Constrained Reliability (DCR), which measures the probability that two nodes remain connected by a path not exceeding a prescribed length bound. This has practical implications in designing networks with bounded delays and fault tolerance, where minimizing diameter ensures faster data transmission and resilience to failures. Research such as [16,17,18,19,20,21] has highlighted that computing DCR is generally NP-hard, but exploiting diameter-based properties allows identification of specific topologies where reliability can be computed in polynomial time. Thus, the study of graph diameter not only advances algebraic graph theory but also plays a key role in optimizing communication systems, transportation routes, and distributed computing architectures. Girth reveals redundancy or minimal algebraic relations among gaps. A small girth may indicate fundamental additive relations in the gap structure. Beyond theory, these invariants are widely used in network reliability and optimization. Networks with low diameter ensure high communication efficiency and resilience, while high girth avoids short feedback loops that can destabilize systems [22].
A numerical semigroup is a subset S N 0 that is closed under addition, contains the zero element, and has a finite complement in N 0 . The elements of N 0 S are called gaps, and their total number is the genus g ( S ) of the semigroup. The Frobenius number F ( S ) is the largest integer not in S , and the multiplicity is the smallest non-zero element of S , denoted by m ( S ) . Given a nonempty set A N 0 , the submonoid generated by A, denoted A , is a numerical semigroup if and only if g c d ( A ) = 1 . Every numerical semigroup has a unique minimal system of generators, and the number of these generators defines the embedding dimension e ( S ) . The Frobenius problem [23,24] explores formulas for calculating the Frobenius number and genus of a numerical semigroup. Sylvester solved this problem in [25] for numerical semigroups with embedding dimension two. Because of their applications in coding theory, algebraic geometry, and factorization theory, numerical semigroups have received much attention in algebraic and combinatorial research over the last few decades. Several structural features have been investigated, including symmetric, pseudo-symmetric, and nearly symmetric semigroups [26]. The link between numerical semigroups and Apéry sets, Kunz coordinates, and their representation through combinatorial objects such as trees and posets has been widely studied in the literature [27,28], providing powerful tools for categorization and computing.
Partially ordered sets (posets) are mathematical structures composed of elements connected by a binary relation that is reflexive, antisymmetric, and transitive. This framework allows for the representation of relationships where not all the elements are comparable, making it useful in various fields, including computer science, combinatorics, and chemistry. Wachs [29] provided a comprehensive overview of poset theory and its connections with topology, particularly in understanding the structure of order complexes. Felsner et al. [30] proposed the concept of poset dimension, which has been further examined in following surveys, showing how posets can be represented as linear-order intersections and how this relates to computing complexity. De Loof et al. [31] demonstrated that posets may be utilized for multi-criteria ranking, which is useful in decision-making systems like chemical assessments and preference models. Posets also have a role in coding theory as they are utilized to define novel distance measures for error correction, as explained in Springer’s work on poset metrics. Additionally, posets have been extensively studied in the context of algebraic structures such as distributive lattices and Boolean algebras, leading to significant results in universal algebra and logic [32].
Posets are commonly formed in algebraic combinatorics from monomial ideals, numerical semigroups, and group actions, and they provide a convenient framework for defining simplicial complexes, resolving homological dimensions, and storing algebraic constraints in graphical form.
Several computational tools exist for the study of numerical semigroups, most notably the numericalsgps package in the GAP system, which provides a wide range of algebraic and combinatorial functionalities. While these packages are powerful, they often require familiarity with specialized algebraic software and may not provide immediate visualization features for graph structures. Our approach differs in that it leverages Python version 3.13.5, a widely accessible programming language, together with graph-theoretic libraries such as NetworkX and visualization packages like Matplotlib version 3.5. This makes it possible to construct, analyze, and visualize gap poset graphs in an integrated manner. Furthermore, our method is easily extensible to compute new invariants that are not yet implemented in standard packages. Thus, while the existing software emphasizes algebraic operations on semigroups, our contribution lies in providing a flexible user-friendly framework that directly bridges numerical semigroup theory with graph theory and visualization.
The remainder of this paper is organized as follows. In Section 2, we determine the conditions under which bipartite gap poset graphs are connected or disconnected. In Section 3, we characterize the bipartite gap poset graphs into different well-known families of graphs. In Section 4, we provide a bound on the diameter and a conjecture on the upper bound of the girth of a bipartite gap poset graph. In Section 5, we present the algorithms for constructing gap poset graphs, along with procedures to compute key graph invariants, such as diameter and girth. This paper concludes in Section 6.

2. Some Results on Connectedness of Bipartite Gap Poset Graphs

Let x , y G , where G is the set of gaps of numerical semigroup S , and then y S x if and only if x y S . Evidently, ( G , S ) is a poset. An undirected simple graph J G ( S ) is a graph such that
V ( J G ( S ) ) = { v x : x G } ,
and
E ( J G ( S ) ) = { v x v y x S y o r y S x } .
A numerical semigroup S is elementry if and only if F ( S ) < 2 m ( S ) . This implies that gap set G of S is of the form { 1 , 2 , , m ( S ) 1 } A , where A { m ( S ) + 1 , m ( S ) + 2 , , 2 m ( S ) 1 } . It is demonstrated in [33] (see Theorem 2) that, if A is empty, then J G ( S ) is an edgeless graph. In this paper, we consider A is always non-empty, and therefore m ( S )     | J G ( S ) |     2 m ( S ) 2 . The following theorem demonstrates correspondence between the elementary numerical semigroups and the bipartite gap poset graphs.
Theorem 1. 
A numerical semigroup S is elementary if and only if the gap poset graph J G ( S ) is a bipartite graph.
Proof. 
( ) This implication follows from Lemma 2.1 of [33].
( ) Suppose J G ( S ) is a bipartite graph but S is not an elementary numerical semigroup. Then, from Theorem 2.4 of [33], it follows that girth of J G ( S ) is 3, which is not possible as J G ( S ) is a bipartite graph. Hence, S is an elementary numerical semigroup. □
In the rest of paper, we denote a bipartite gap poset graph by B G ( S ) . The following lemma provides us necessary and sufficient conditions for the connectedness of B G ( S ) in terms of the Frobenius number of S .
Lemma 1. 
Let B G ( S ) be a bipartite gap poset graph and V ( B G ( S ) ) = V 1 V 2 , where V 1 = { v 1 , v 2 , , v m ( S ) 1 } and V 2 { v m ( S ) + 1 , v m ( S ) + 2 , , v 2 m ( S ) 1 } . Then, the following statements hold:
(1) 
If B G ( S ) is connected, then F ( S ) = 2 m ( S ) 1 .
(2) 
If F ( S ) = 2 m ( S ) 1 and for every i , j { 1 , 2 , , m ( S ) 1 } , N ( v i ) N ( v j ) , then B G ( S ) is connected.
Proof. 
(1) If F ( S ) 2 m ( S ) 1 , then F ( S ) = m ( S ) + x for some x { 1 , 2 , , m ( S ) 2 } . Note that
( m ( S ) + x ) ( m ( S ) 1 ) = x + 1 S ,
as min ( x + 1 ) = 2 and max ( x + 1 ) = m ( S ) 1 . This implies v m ( S ) 1 has no edge with any vertex of V 2 . This is a contradiction as B G ( S ) is a connected graph; therefore, the Frobenius number of S must be 2 m ( S ) 1 .
(2) We need to show that there is path between every two distinct vertices u , v V ( B G ( S ) ) . For this, we have the following cases:
  • Case-1: If u , v V 1 , then there exist some w V 2 such that u w v is a path between u and v.
  • Case-2: Let u , v V 2 , and then we may assume that u = v m + x and v = v m + y , where x , y { 1 , 2 , , m 1 } with x y . This implies there exist v x , v y V 1 such that v m + x has an edge with v x and v m + y has an edge with v y since ( m ( S ) + x ) x = m ( S ) = ( m ( S ) + y ) y . Consider v m + z N ( v x ) N ( v y ) for some z { 1 , 2 , , m 1 } . This implies a path between u and v is u v x v m + z v y v .
  • Case-3: Let u V 1 and v V 2 . Assume that v = v m + x for some x { 1 , 2 , , m 1 } . If  u = v x , then u and v are connected by an edge, so we have u v . Now, if u v x , then there exist some v m + z N ( u ) N ( v x ) for some z { 1 , 2 , , m 1 } such that u v m + z v x v . □
If F ( S ) = 2 m ( S ) 1 , then B G ( S ) may be disconnected (see the following example).
Example 1. 
Let S = 5 , 7 , 8 , 11 , and then gap poset of S is G = { 1 , 2 , 3 , 4 , 6 , 9 } . The corresponding graph B G ( S ) is given in Figure 1. Clearly, F ( S ) = 2 ( 5 ) 1 , but  B G ( S ) is a disconnected graph.

3. Characterization of Bipartite Gap Poset Graphs of Minimum and Maximum Orders

We start this section by characterizing bipartite gap poset graphs of minimum order.
Proposition 1. 
Let B G ( S ) be a bipartite gap poset graph of order m ( S ) and F ( S ) = 2 m ( S ) 1 , and then B G ( S ) is connected.
Proof. 
We have F ( S ) + 1 2 = m ( S ) = | G | . This implies S is symmetric; then, from Proposition 2.2 of [33], it follows that B G ( S ) is a connected graph. □
Proposition 2. 
Let B G ( S ) be a disconnected bipartite gap poset graph of order m ( S ) , and then B G ( S ) has 2 m ( S ) F ( S ) disconnected components.
Proof. 
Since B G ( S ) is a disconnected bipartite poset graph of order m ( S ) , therefore we have
V ( B G ( S ) ) = { v 1 , v 2 , , v m ( S ) 1 } { v F ( S ) } ,
where v F ( S ) { v m ( S ) + 1 , v m ( S ) + 2 , , v 2 m ( S ) 2 } . We may assume that F ( S ) = m ( S ) + g for some g { 1 , 2 , , m ( S ) 2 } . Choose x { 1 , 2 , , m ( S ) 1 } such that 1     g < x     m ( S ) 1 , and then 1 < m ( x g ) < m ( S ) 1 . This yields m ( S ) + g x S for every value of x. So, number of vertices v i for  1     i     m ( S ) 1 that are not connected with the vertex v F ( S ) is m ( S ) g 1 . This implies total number of disconnected components of B G ( S ) is m ( S ) g = 2 m ( S ) F ( S ) . □
Theorem 2. 
Let B G ( S ) be a bipartite graph of order m ( S ) . Then, the following statements are equivalent:
(1) 
S is an interval numerical semigroup of embedding dimension m ( S ) 1 .
(2) 
S is a symmetric numerical semigroup.
(3) 
The graph B G ( S ) is isomorphic to the star graph K 1 , m ( S ) 1 .
Proof. 
Since B G ( S ) is a bipartite graph of order m ( S ) , therefore we have
V ( B G ( S ) ) = { v 1 , v 2 , , v m ( S ) 1 } { v x } ,
where v x { v m ( S ) + 1 , v m ( S ) + 2 , , v 2 m ( S ) 1 } .
  • ( 1 ) ( 2 ) : This is obvious.
  • ( 2 ) ( 3 ) : If S is symmetric, then Proposition 1 provides B G ( S ) , a connected graph, and gr ( B G ( S ) ) { 3 , } . This implies every vertex v i for 1     i     m ( S ) 1 has an edge with the vertex v x . As  B G ( S ) is a bipartite graph, therefore gr ( B G ( S ) ) cannot be 3, so B G ( S ) K 1 , m ( S ) 1 .
  • ( 3 ) ( 1 ) : This is straightforward. □
Theorem 3. 
The graph B G ( S ) is a complete bipartite graph if and only if B G ( S ) is a star graph.
Proof. 
If B G ( S ) is a complete bipartite graph, then
V ( B G ( S ) ) = { v 1 , v 2 , , v m ( S ) 1 } B ,
where B { v m ( S ) + 1 , v m ( S ) + 2 , , v 2 m ( S ) 1 } . If possible, | B | > 1 , and then there exist m ( S ) + x B for some x { 1 , 2 , , m ( S ) 2 } . Note that
( m ( S ) + x ) ( m ( S ) 1 ) = x + 1 S .
This is a contradiction, so | B | = 1 and therefore B G ( S ) is a star graph. The converse implication is obvious. □
Theorem 4. 
Let B G ( S ) be a bipartite graph of order m ( S ) . Then, the following statements are equivalent:
(1) 
S is a numerical semigroup of the form m ( S ) , m ( S ) + 1 , , 2 m ( S ) 3 , 2 m ( S ) 1 .
(2) 
S is a pseudo-symmetric numerical semigroup.
(3) 
The graph B G ( S ) is isomorphic to the graph K 1 , m ( S ) 2 { v m ( S ) 1 } .
Proof. 
Since B G ( S ) is a bipartite graph of order m ( S ) , therefore we have
V ( B G ( S ) ) = { v 1 , v 2 , , v m ( S ) 1 } { v x } ,
where v x { v m ( S ) + 1 , v m ( S ) + 2 , , v 2 m ( S ) 1 } .
  • ( 1 ) ( 2 ) : This is obvious.
  • ( 2 ) ( 3 ) : If S is pseudo-symmetric, then
    F ( S ) + 2 2 = | B G ( S ) | = m ( S ) .
  • This implies F ( S ) = 2 m ( S ) 2 , and therefore F ( S ) 2 = m ( S ) 1 . Theorem 2.5 of [33] and Proposition 2 indicate that B G ( S ) has two disconnected components and isomorphic to K 1 , m ( S ) 2 { v m ( S ) 1 } .
  • ( 3 ) ( 1 ) : This is straightforward. □
Theorem 5. 
Let B G ( S ) be a bipartite gap poset graph. Then, the following statements are equivalent:
(1) 
| B G ( S ) | = 2 m ( S ) 2 .
(2) 
B G ( S ) is a graph isomorphic to ( m ( S ) 1 ) P 2 .
(3) 
B G ( S ) is a 1-degree regular bipartite graph.
(4) 
B G ( S ) is a balanced graph.
Proof. 
( 1 ) ( 2 ) : We may assume that bipartition for B G ( S ) is V 1 = { v x : 1     x     m ( S ) 1 } and V 2 = { v m ( S ) + x : 1     x     m ( S ) 1 } . Note that m ( S ) + x x = m ( S ) S . This implies, for every 1     x     m ( S ) 1 , there is an edge between v x and v m ( S ) + x . If  1     x < y     m ( S ) 1 , then ( m + x ) y { 1 , 2 , , m ( S ) 1 } . Also, if  1     y < x     m ( S ) 1 , then ( m + x ) y { m ( S ) + 1 , m ( S ) + 1 , , 2 m ( S ) 2 } . Both cases imply there is no edge between v y and v m ( S ) + x . This provides deg ( v m ( S ) + x ) = 1 for every x, and therefore B G ( S ) is isomorphic to ( m ( S ) 1 ) -copies of path graph P 2 .
  • The remaining implications are trivial. □

4. Diameter and Girth of Bipartite Gap Poset Graphs

In this section, we provide some bounds for the diameter and the girth of bipartite gap poset graphs B G ( S ) .
Lemma 2. 
Let order of B G ( S ) be 2 m ( S ) 3 . If  m ( S ) + 1 S , then B G ( S ) is disconnected.
Proof. 
Clearly, two vertices v x V 1 and v y V 2 have an edge only if y x { m ( S ) , m ( S ) + r , for some 2     r     m ( S ) 2 } . This implies deg ( v y ) { 1 , 2 } , for every v y V 2 . Since m ( S ) + 1 , , m ( S ) + r 1 < m ( S ) + r , then
d e g ( v p ) = 1 , m ( S ) + 1     p     m ( S ) + r 1 ,
and
d e g ( v q ) = 2 , m ( S ) + r + 1     q     2 m ( S ) 1 .
This provides
| E ( B G ( S ) ) |     1 ( r 1 ) + 2 ( m ( S ) r 1 ) = 2 m ( S ) r 3 < ( 2 m ( S ) 3 ) 1 = | B G ( S ) | 1 .
This implies B G ( S ) is disconnected. □
Theorem 6. 
Let order of B G ( S ) be 2 m ( S ) 3 . Then, m ( S ) + 1 S if and only if B G ( S ) P 2 m ( S ) 3 .
Proof. 
( ) If m ( S ) + 1 S , then gap poset for S is
G = { 1 , 2 , m ( S ) 1 } { m ( S ) + k : 2     k     m ( S ) 1 } .
Note that ( m ( S ) + 2 ) 1 = m ( S ) + 1 S and ( 2 m ( S ) 1 ) ( m ( S ) 1 ) = m ( S ) S , while ( m ( S ) + l ) 1 = m ( S ) + ( l 1 ) S , for  3     l     m 1 and ( m ( S ) + t ) ( m ( S ) 1 ) = t + 1 S , for  2     t     m 2 . This implies deg ( v 1 ) = 1 = deg ( v m 1 ) . Also, for each 2     x     m ( S ) 1 and 1     y     m ( S ) 1 , ( m ( S ) + x ) y S if and only if either y = x or y = x 1 . This implies
v 1 v m ( S ) + 2 v 2 v m ( S ) + 3 v 3 v m ( S ) 2 v 2 m ( S ) 1 v m ( S ) 1 .
Consequently, we obtain the required result.
  • ( ) This follows from Lemma 2. □
Conjecture 1. 
Let B G ( S ) be a bipartite gap poset graph. If  m ( S ) is the multiplicity of numerical semigroup S , then diam ( B G ( S ) )     2 m ( S ) 4 .
Now, we propose the following conjecture for the girth of bipartite gap poset graphs.
Conjecture 2. 
Let B G ( S ) be a connected bipartite gap poset graph containing a finite cycle. If  m ( S ) 6 is the multiplicity of numerical semigroup S , then one of the following statements hold:
(1) 
If m ( S ) is odd, then g r ( B G ( S ) )     m ( S ) 1 .
(2) 
If m ( S ) is even, then g r ( B G ( S ) ) { 4 , 6 } .
In the following results, we prove this conjecture for connected bipartite gap poset graphs of order 2 m ( S ) 4 .
Proposition 3. 
Let B G ( S ) be a connected bipartite gap poset graph of order 2 m ( S ) 4 containing a finite cycle, and then g r ( B G ( S ) )     m ( S ) 1 , where m ( S ) 7 is an odd number.
Proof. 
First of all, we show that there is some A { m ( S ) + 1 , m ( S ) + 2 , , 2 m ( S ) 1 } such that B G ( S ) contains a cycle of length m ( S ) 1 . For this, we consider
A = { m ( S ) + 1 , , 3 m ( S ) 5 2 , 3 m ( S ) + 1 2 , , 2 m ( S ) 1 } .
Note that two vertices v i , v j V ( B G ( S ) ) are connected if and only if i j { m ( S ) , 3 m ( S ) 3 2 , 3 m ( S ) 1 2 } . Since m ( S ) + 1 , , 3 m ( S ) 5 2 < 3 m ( S ) 3 2 and graph is connected, then
d e g ( v i ) = 1 , m ( S ) + 1     i     3 m ( S ) 5 2 .
For each 1     x     m ( S ) 1 2 , we have
3 m ( S ) 1 2 + x x = 3 m ( S ) 1 2 ,
3 m ( S ) 1 2 + x ( x + 1 ) = 3 m ( S ) 3 2 ,
3 m ( S ) 1 2 + x ( m ( S ) 1 2 + x ) = m ( S ) .
This implies d e g ( v j ) = 3 , 3 m ( S ) + 1 2     j     2 m ( S ) 1 , and  d e g ( v k ) = 1 , m ( S ) + 3 2 + 1     k     m ( S ) 1 . This implies the total number of pendent vertices of B G ( S ) is
( 3 m ( S ) 5 2 m ( S ) 1 + 1 ) + ( m ( S ) 1 m ( S ) + 3 2 + 1 ) = m ( S ) 4 .
Clearly, d e g ( v 1 ) = 2 , but it is not part of any cycle. Thus, only m ( S ) 1 vertices are part of a cycle. The above discussion implies B G ( S ) is a graph as in the Figure 2.
Now, we have to show that, for any A { m ( S ) + 1 , m ( S ) + 2 , , 2 m ( S ) 1 } , graph B G ( S ) does not contain a cycle of length greater than m ( S ) 1 . For this, we take m + x , m + y S , where m ( S ) 1 2     x     m ( S ) 2 and x + 1     y     m ( S ) 1 . Since
m ( S ) + 1 , , m ( S ) + x 1 < m ( S ) + x ,
therefore
d e g ( v a ) = 1 , m ( S ) + 1     a     m ( S ) + x 1 .
Also, deg ( v m ( S ) + 1 2 + u ) = 1 , 1     u     m ( S ) 3 2 since an element L B has an edge if it satisfies the following condition:
L ( m ( S ) + 1 2 + u ) = m ( S ) o r m ( S ) + x o r m ( S ) + y .
Note that
L = m ( S ) + ( m ( S ) + 1 2 + u ) = 3 m ( S ) + 1 2 + u B ,
L = m ( S ) + x + ( m ( S ) + 1 2 + u ) = 3 m ( S ) + 1 2 + u + x > F B ,
L = m ( S ) + y + ( m ( S ) + 1 2 + u ) = 3 m ( S ) + 1 2 + y + u > F B .
This implies the total number of pendent vertices of B G ( S ) is
( m ( S ) + x 1 m ( S ) 1 + 1 ) + ( m ( S ) 3 2 ) = m ( S ) 3 2 + x 1 ,
and
2 m ( S ) 4 ( m ( S ) 3 2 + x 1 ) = 3 m ( S ) 3 2 2 x < m ( S ) 1 .
This indicates that the number of vertices with degree greater than 1 is less than m ( S ) 1 . This implies B G ( S ) cannot contain a cycle of length greater than m ( S ) 1 .
  • If x = m ( S ) 3 2 and m ( S ) + 1 2     y     m ( S ) 2 , then
    d e g ( v a ) = 1 , m ( S ) + 1     a     3 m ( S ) 5 2 ,
    d e g ( v b ) = 2 , 3 m ( S ) 1 2     b     m ( S ) + y 1 ,
    d e g ( v c ) = 3 , m ( S ) + y + 1     c     2 m ( S ) 1 .
  • So,
    | E ( B G ( S ) ) | = ( 2 m ( S ) 5 2 m ( S ) 1 + 1 ) + 2 ( m ( S ) + y 1 3 m ( S ) 1 2 + 1 ) +
    3 ( 2 m ( S ) 1 m ( S ) y 1 + 1 ) = 2 m ( S ) 4 + m ( S ) 1 2 y     | B G ( S ) | 1 .
  • This implies B G ( S ) is either a path or disconnected graph, which is not possible.
  • If 2     x     m ( S ) 1 2 , 1     y     x 1 and y m ( S ) 3 2 , then there exists a cycle
    v y + 1 v m ( S ) + y + 1 v 1 v m ( S ) + x + 1 v x + 1 v m ( S ) + x + y + 1 v y + 1 .
  • Consequently, there is no cycle of length greater than m ( S ) 1 .
  • If 1     x     m ( S ) 5 2 , m ( S ) 1 2     y     2 m ( S ) 1 , then there exists a cycle
    v m ( S ) + y + 1 v y + 1 v m ( S ) + y + 1 + x v x + 1 v m ( S ) + x + 1 v 1 v m ( S ) + y + 1 .
  • This implies there is no cycle of length greater than m ( S ) 1 .
Proposition 4. 
Let B G ( S ) be a connected bipartite gap poset graph of order 2 m ( S ) 4 containing a finite cycle, and then g r ( B G ( S ) )     6 , where m ( S ) 6 is an even number.
Proof. 
Consider m ( S ) + 1 , 3 m ( S ) 2 S , and then for
A = { m ( S ) + 2 , , 3 m ( S ) 2 1 , 3 m ( S ) 2 + 1 , , 2 m ( S ) 1 } ,
the graph B G ( S ) contains a cycle of length 6 given as follows
v 3 m ( S ) 2 + 1 v 1 v m ( S ) + 2 v 2 v 3 m ( S ) 2 + 2 v m ( S ) 2 + 1 v 3 m ( S ) 2 + 1 .
Now, we have to show that, for any A { m ( S ) + 1 , m ( S ) + 2 , , 2 m ( S ) 1 } , graph B G ( S ) does not contain a cycle of length greater than 6.
( i )
If m ( S ) + 1 , m ( S ) + x S , 2     x     m ( S ) 2 2 , o r m ( S ) + 2 2     x     m ( S ) 1 , then there is a cycle of length 6 in B G ( S ) , given as follows
v m ( S ) + 2 v 1 v m ( S ) + x + 1 v x + 1 v m ( S ) + x + 2 v 2 v m ( S ) + 2 .
( i i )
If 3 m ( S ) 2 + r , 3 m ( S ) 2 + k + 1 S , 0     r     m ( S ) 4 2 , r     k     m ( S ) 4 2 , then
d e g ( v p ) = 1 , m ( S ) + 1     p     3 m ( S ) 2 2 + r ,
d e g ( v q ) = 2 , 3 m ( S ) + 2 2 + r     q     3 m ( S ) 2 + k ,
d e g ( v s ) = 3 , 3 m ( S ) + 4 2 + k     s     2 m ( S ) 1 .
E ( B G ( S ) = ( 3 m ( S ) 2 2 + r m ( S ) 1 + 1 ) + 2 ( 3 m ( S ) 2 + k 3 m ( S ) + 2 2 r ) +
3 ( 2 m ( S ) 1 3 m ( S ) + 4 2 k ) = 2 m ( S ) 7 r k < B G ( S ) 1 .
This implies the corresponding graph is disconnected.
( i i i )
If 3 m ( S ) 2 u , 3 m ( S ) 2 ( l + 1 ) S , 0     u     m ( S ) 4 2 , u     l     m ( S ) 4 2 , then the following cycle is contained in the graph B G ( S ) :
v m ( S ) 2 l v 3 m ( S ) 2 l v 1 v 3 m ( S ) + 2 2 u v m ( S ) + 2 2 u v 2 m ( S ) 1 u l v m ( S ) 2 l .
( i v )
If 3 m ( S ) 2 x , 3 m ( S ) 2 + y S , 1     x     m ( S ) 4 2 , 1     y     m ( S ) 2 2 , then the graph B G ( S ) contains a cycle
v 3 m ( S ) + 2 2 + y v m ( S ) + 2 2 + y v 2 m ( S ) + 1 + y x v m ( S ) + 2 2 x v 3 m ( S ) + 2 2 x v 1 v 3 m ( S ) + 2 2 + y .
Consequently, we obtain gr( B G ( S ) )     6 .  □

5. Algorithms and Python-Based Illustrations

In this section, we propose the algorithms and their Python implementations, followed by illustrative examples, as well as their application in chemical reaction networks.
Time complexity and space complexity of Algorithm 1 are quadratic and equal to O ( K M + M 2 ) , O ( M 2 ) , respectively, where K is the number of minimal generators of the numerical semigroup and M is computed upper bound. For two generators a and b, M = m a x ( 2 ( a b a b ) , 100 ) , and for more than two generators M = 100 m a x ( H ) .
Algorithm 1 Construction of Gap Poset Graph of a Numerical Semigroup
Input: 
H = { h 1 , h 2 , , h k } , the minimal system of generator of numerical semigroup S .
Output: 
Gap poset graph B G ( S ) .
  1:
S
  2:
frontier [ 0 ]
  3:
while  frontier  do
  4:
       current pop ( frontier )
  5:
      if current > max_limit then
  6:
            continue
  7:
      end if
  8:
      if  current S  then
  9:
            add current to S
10:
            for all  h H  do
11:
                   push current + h to frontier
12:
            end for
13:
      end if
14:
end while
15:
Gaps { x N 0 0     x < max ( S ) x S }
16:
if  | Gaps | 2  then
17:
     max_check sum of two largest elements of gaps
18:
else
19:
     max_check 3 · max ( H )
20:
end if
21:
S , frontier [ 0 ]
22:
Repeat step 3 14   with max_limit max_check
23:
Gaps { x N 0 0     x < max_check x S }
24:
Initialize empty gap poset graph B G ( S )
25:
for all  ( a , b ) Gaps with a < b   do
26:
    if  | a b | S  then
27:
        Add edge ( a , b ) to gap poset graph B G ( S )
28:
    end if
29:
end for
30:
return  B G ( S ) , Gaps , EdgeList
Time complexity is cubic O ( K M + M 3 ) , and space complexity is quadratic O ( M 2 ) of Algorithm 2, where K is the number of minimal generators of numerical semigroups and M is computed upper bound. For two generators a and b, M = m a x ( 2 ( a b a b ) , 100 ) , and for more than two generators M = 100 m a x ( H ) . To assist researchers and support the validation and exploration of results in the study of numerical semigroups, we developed a Python-based tool that allows users to construct gap poset graphs derived from a given numerical semigroup S . The tool provides functionality to compute important graph invariants, such as the diameter and girth of the resulting gap poset graphs. The tool can be accessed through the following link: https://gap-poset-graph-analyzer.onrender.com/ (accessed on 22 July 2025).
Algorithm 2 Compute the Diameter and the Girth of Gap Poset Graph
Input: 
H = { h 1 , h 2 , , h k } , the minimal system of generator of numerical semigroup S
Output: 
Diameter and the girth of gap poset graph B G ( S )
  1:
if length of generators is 2 then
  2:
    Let a , b sorted generators
  3:
     frobenius a b a b
  4:
    max_limit max ( 2 · frobenius , 100 )
  5:
else
  6:
    max_limit 100 · max ( generators )
  7:
end if
  8:
Initialize numerical semigroup S and frontier queue with 0
  9:
while frontier is not empty do
10:
    Pop current element
11:
    if current > max_limit then continue
12:
    end if
13:
    if current S  then
14:
        Add current to S
15:
        for all  h H  do
16:
           Append c u r r e n t + h to frontier
17:
        end for
18:
    end if
19:
end while
20:
g a p s { x x S , x < max ( S ) }
21:
Create empty graph B G ( S ) and add g a p s as nodes
22:
for all pairs ( i , j ) in g a p s  do
23:
     d i f f | i j |
24:
    if  d i f f S  then
25:
        Add edge ( i , j ) to B G ( S )
26:
    end if
27:
end for
28:
if  B G ( S ) is connected then
29:
    Compute and return diameter ( B G ( S ) )
30:
else
31:
    Report number of components; diameter not defined
32:
end if
33:
Compute girth via BFS:
34:
for node in a subset of B G ( S )  do
35:
    Perform BFS and track shortest cycles
36:
    if cycle of length 3 found then
37:
        return 3 as girth
38:
    end if
39:
end for
40:
Return minimum cycle length as girth (or if none)
Example 2. 
Let S = 13 , 18 , 19 , 27 , 28 , 29 , 30 , 33 , 34 , 35 , 42 , and then we can use the following Python code to calculate the gap poset graph B G ( S ) and its diameter and girth (see Listing 1).
As illustrated in Figure 3, the ordered set of nodes { 20 , 2 , 21 , 3 , 22 , 4 , 23 , 5 , 24 , 6 , 25 , 7 } forms the shortest cycle in the graph. Since each pair of consecutively listed nodes is connected by an edge, this implies shortest cycle has length 12, which establishes the girth of B G ( S ) as 12. Furthermore, the largest distance between any two vertices occurs between nodes 14 and 10, yielding graph of diameter 9.
Listing 1. Python console output.
Axioms 14 00669 i001
Suppose a synthetic chemist needs to transform an initial molecular state (a short oligomer or intermediate) into a target state (a longer oligomer or final product) by a sequence of elementary reactions. Each elementary reaction can change molecular size by a quantity belonging to a fixed set of allowed step sizes (for instance, additions of building blocks of sizes given by available reagents). We model the allowed step sizes by gaps of numerical semigroup S = 13 , 18 , 19 , 27 , 28 , 29 , 30 , 33 , 34 , 35 , 42 such that nodes represent molecular species (substrates, intermediate, and product) and edges correspond to stoichiometrically possible reaction steps. The gap poset graph indicates hypothetically how many one-step reactions take place (i.e., direct edge between vertices) and two-step reactions (i.e., there is a vertex between two independent vertices that link with both of them) and so on. Diameter and girth of gap poset graphs provide information about how long any synthesis path can be and on the minimal length of possible cycles, which helps chemists and engineers to estimate worst-case synthesis depth and detect when a proposed reagent set is intrinsically inefficient. Also, it helps us in energy minimization, yield optimization, selection of catalyst, and alternative reagents.
Example 3. 
Let S = 8 , 10 , 11 , 12 , 17 , and then we can use the following Python code to compute the gap poset graph B G ( S ) and its diameter and girth (see Listing 2).
Listing 2. Python console output.
Axioms 14 00669 i002
As illustrated in Figure 4, the ordered set of nodes { 15 , 4 , 14 , 3 , 15 } forms the shortest cycle in the graph. Since each pair of consecutively listed nodes is connected by an edge, this implies shortest cycle has length 4, which establishes the girth of B G ( S ) as 4. Furthermore, the largest distance between any two vertices occurs between nodes 7 and 9, yielding graph has diameter 5 .

6. Conclusions

In this article, we investigated various structural properties of bipartite gap poset graphs associated with numerical semigroups. In Section 2, we determined the specific conditions under which they are connected or disconnected, providing insight into how the arrangement of gaps affects the overall structure. In Section 3, we concentrated on the characterization of bipartite gap poset graphs, in which we investigated how various configurations corresponded to different well-known graph types, such as balanced, path, and star. In Section 4, we provided a bound on the diameter of bipartite gap poset graphs. Additionally, we provided a conjecture on the upper bound of the girth of bipartite gap poset graphs. These findings help to deepen our understanding of the interaction between the additive structure of numerical semigroups and the combinatorial features of their related graphs, as well as open up new possibilities for research in algebraic graph theory. In Section 5, we presented the algorithms for constructing gap poset graphs, along with procedures to compute key graph invariants such as diameter and girth. Additionally, this section includes illustrative examples that demonstrate the practical application and effectiveness of the proposed methods.
The future extension is to investigate gap poset graphs beyond the bipartite case, exploring richer families of numerical semigroups and the new structural patterns they generate. Furthermore, studying additional graph invariants, including the chromatic number, domination number, and metric dimension of these graphs, would provide deeper insights into their structural and combinatorial properties.   

Author Contributions

Conceptualization, M.M., S.S.A. and K.M.; Methodology, M.A.B. and A.S.A.; Software, K.M.; Formal analysis, M.M. and S.S.A.; Investigation, M.A.B., A.S.A. and K.M.; Writing—original draft, M.M. and A.S.A.; Writing—review & editing, M.A.B. and S.S.A.; Visualization, K.M.; Supervision, M.A.B. and S.S.A.; Project administration, A.S.A.; Funding acquisition, A.S.A. All authors have read and agreed to the published version of the manuscript.

Funding

The study was funded by Princess Nourah bint Abdulrahman University in Riyadh, Saudi Arabia, under Researchers Supporting Project Number (PNURSP2025R231). The authors would like to express their gratitude to the university for this support.

Data Availability Statement

Data is contained within the article.

Acknowledgments

The study was funded by Princess Nourah bint Abdulrahman University in Riyadh, Saudi Arabia, under Researchers Supporting Project Number (PNURSP2025R231). The authors would like to express their gratitude to the university for this support.

Conflicts of Interest

The authors declare no conflicts of interest.

References

  1. Cameron, P.J. What can graphs and algebraic structures say to each other? AKCE Int. J. Graphs Comb. 2024, 21, 249–254. [Google Scholar] [CrossRef]
  2. Easttom, C. On the application of algebraic graph theory to modeling network intrusions. In Proceedings of the 2020 10th Annual Computing and Communication Workshop and Conference (CCWC), Las Vegas, NV, USA, 6–8 January 2020. [Google Scholar]
  3. Cayley, P. Desiderata and suggestions: No. 2. The Theory of groups: Graphical representation. Am. J. Math. 1878, 1, 174–176. [Google Scholar] [CrossRef]
  4. Beck, I. Coloring of commutative rings. J. Algebra 1988, 116, 208–226. [Google Scholar] [CrossRef]
  5. Anderson, D.F.; Livingston, P.S. The zero-divisor graph of a commutative ring. J. Algebra 1999, 217, 434–447. [Google Scholar] [CrossRef]
  6. Anderson, D.F.; Badawi, A. The total graph of a commutative ring. J. Algebra 2008, 320, 2706–2719. [Google Scholar] [CrossRef]
  7. Bennis, D.; Mikram, J.; Taraza, F. On the extended zero divisor graph of commutative rings. Turk. J. Math. 2016, 40, 376–388. [Google Scholar] [CrossRef]
  8. Binyamin, M.A.; Siddiqui, H.M.A.; Khan, N.M.; Aslam, A.; Rao, Y. Characterization of graphs associated with numerical semigroups. Mathematics 2019, 7, 557. [Google Scholar] [CrossRef]
  9. Alali, A.S.; Binyamin, M.A.; Mehtab, M. A conjecture for the Clique number of graphs associated with symmetric numerical semigroups of arbitrary multiplicity and embedding dimension. Symmetry 2024, 16, 854. [Google Scholar] [CrossRef]
  10. Xu, P.; Binyamin, M.A.; Aslam, A.; Ali, W.; Mahmood, H.; Zhou, H. Characterization of graphs associated with the ideal of numerical semigroups. J. Math. 2020, 2020, 6094372. [Google Scholar] [CrossRef]
  11. Wang, Y.; Binyamin, M.A.; Ali, W.; Aslam, A.; Rao, Y. Graphs associated with the ideals of a numerical semigroup having metric dimension 2. Math. Probl. Eng. 2021, 2021, 6697980. [Google Scholar] [CrossRef]
  12. Binyamin, M.A.; Ali, W.; Aslam, A.; Mahmood, H. A complete classification of planar graphs associated with the ideal of the numerical semigroup. Iran. J. Sci. Technol. Trans. A Sci. 2022, 46, 491–498. [Google Scholar] [CrossRef]
  13. Sachdeva, K. Applications of Graphs in Real-Life. Int. J. Adv. Res. Comput. Sci. 2012, 3, 403. [Google Scholar]
  14. Jolion, J.M.; Kropatsch, W. (Eds.) Graph Based Representations in Pattern Recognition; Springer Science and Business Media: Cham, Switzerland, 2012. [Google Scholar]
  15. Zhang, X.; Nadeem, M.; Ahmad, S.; Siddiqui, M.K. On applications of bipartite graph associated with algebraic structures. Mathematics 2020, 18, 57–66. [Google Scholar] [CrossRef]
  16. Petingi, L.; Rodriguez, J. Reliability of networks with delay constraints. Congr. Numer. 2001, 152, 117–124. [Google Scholar]
  17. Satyanarayana, A.; Wood, R.K. Polygon-to-Chain Reductions and Network Reliability (No. ORCRR824); Operations Research Center, University of California: Berkeley, CA, USA, 1982. [Google Scholar]
  18. Satyanarayana, A.; Wood, R.K. A linear-time algorithm for computing K-terminal reliability in series-parallel networks. SIAM J. Comput. 1985, 14, 818–832. [Google Scholar] [CrossRef]
  19. Satyarayanana, A.; Chang, M. Network reliability and the factoring theorem. Networks 1983, 13, 107–120. [Google Scholar] [CrossRef]
  20. Wood, R.K. A factoring algorithm using polygon-to-chain reductions for computing K-terminal network reliability. Networks 1985, 15, 173–190. [Google Scholar] [CrossRef]
  21. Wood, R.K. Factoring algorithms for computing K-terminal network reliability. IEEE Trans. Reliab. 2007, 35, 269–278. [Google Scholar] [CrossRef]
  22. Petingi, L. Diameter-related properties of graphs and applications to network reliability theory. Reliab. Vulnerability Model. Its Appl. 2013, 12, 884–894. [Google Scholar]
  23. Rosales, J.C.; García-Sánchez, P.A. Numerical Semigroups; Springer: New York, NY, USA, 2009. [Google Scholar]
  24. Bras-Amorós, M. Fibonacci-like behavior of the number of numerical semigroups of a given genus. Semigroup Forum 2008, 76, 379–384. [Google Scholar] [CrossRef]
  25. Sylvester, J.J. Mathematical questions with their solutions. Educ. Times 1884, 41, 171–178. [Google Scholar]
  26. Barucci, V.; Dobbs, D.E.; Fontana, M. Maximality properties in numerical semigroups, with applications to one-dimensional analytically irreducible local domains. In Commutative Ring Theory; CRC Press: Boca Raton, FL, USA, 2023; pp. 13–25. [Google Scholar]
  27. Eliahou, S. Wilf’s conjecture and Macaulay’s theorem. J. Eur. Math. Soc. 2018, 20, 2105–2129. [Google Scholar] [CrossRef]
  28. Delgado, M.; García-Sánchez, P.A. Numericalsgps, a GAP package for numerical semigroups. ACM Commun. Comput. Algebra 2016, 50, 12–24. [Google Scholar] [CrossRef]
  29. Wachs, M.L. Poset topology: Tools and applications. arXiv 2006, arXiv:math/0602226. [Google Scholar] [CrossRef]
  30. Felsner, S.; Trotter, W.T.; Wiechert, V. The dimension of posets with planar cover graphs. Graphs Comb. 2015, 31, 927–939. [Google Scholar] [CrossRef]
  31. De Loof, K.; De Baets, B.; De Meyer, H.; Bruggemann, R. A hitchhiker’s guide to poset ranking. Comb. Chem. Andhigh Throughput Screen. 2008, 11, 734–744. [Google Scholar] [CrossRef]
  32. Gratzer, G.A. Lattice Theory: Foundation; Springer: Basel, Switzerland, 2011. [Google Scholar]
  33. Binyamin, M.; Alali, A.; Mahmood, H. On Connectedness, Girth and Diameter of Gap Poset Graphs. Proc. Bulg. Acad. Sci. 2025, 78, 813–820. [Google Scholar] [CrossRef]
Figure 1. The graph B G ( S ) corresponding to G .
Figure 1. The graph B G ( S ) corresponding to G .
Axioms 14 00669 g001
Figure 2. The graph B G ( S ) corresponding to A .
Figure 2. The graph B G ( S ) corresponding to A .
Axioms 14 00669 g002
Figure 3. Gap poset graph for numerical semigroup S = 13 , 18 , 19 , 27 , 28 , 29 , 30 , 33 , 34 , 35 , 42 .
Figure 3. Gap poset graph for numerical semigroup S = 13 , 18 , 19 , 27 , 28 , 29 , 30 , 33 , 34 , 35 , 42 .
Axioms 14 00669 g003
Figure 4. Gap poset graph for 8 , 10 , 11 , 12 , 17 .
Figure 4. Gap poset graph for 8 , 10 , 11 , 12 , 17 .
Axioms 14 00669 g004
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

Mehtab, M.; Binyamin, M.A.; Asghar, S.S.; Alali, A.S.; Mehmood, K. On Structural Characterization and Computation of the Diameter and Girth of Bipartite Gap Poset Graphs with Python Application. Axioms 2025, 14, 669. https://doi.org/10.3390/axioms14090669

AMA Style

Mehtab M, Binyamin MA, Asghar SS, Alali AS, Mehmood K. On Structural Characterization and Computation of the Diameter and Girth of Bipartite Gap Poset Graphs with Python Application. Axioms. 2025; 14(9):669. https://doi.org/10.3390/axioms14090669

Chicago/Turabian Style

Mehtab, Maria, Muhammad Ahsan Binyamin, Syed Sheraz Asghar, Amal S. Alali, and Khawar Mehmood. 2025. "On Structural Characterization and Computation of the Diameter and Girth of Bipartite Gap Poset Graphs with Python Application" Axioms 14, no. 9: 669. https://doi.org/10.3390/axioms14090669

APA Style

Mehtab, M., Binyamin, M. A., Asghar, S. S., Alali, A. S., & Mehmood, K. (2025). On Structural Characterization and Computation of the Diameter and Girth of Bipartite Gap Poset Graphs with Python Application. Axioms, 14(9), 669. https://doi.org/10.3390/axioms14090669

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