Manuscript Offprint
arXiv:2610.13452Deterministic Girth Approximation in Weighted Undirected Graphs
Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.
Abstract
We give deterministic algorithms for approximating the girth of an undirected graph with vertices, edges, and nonnegative real edge lengths. For every integer , our algorithm returns a cycle of length at most in worst-case time. For every constant , this matches the stretch and the expected running time of the randomized algorithms of Kadria, Roditty, Sidford, Vassilevska Williams, and Zwick [SODA'23, SICOMP'26] and Kadria, Roditty, and Vassilevska Williams [ESA'26]. In general, it loses only a factor of in the term that depends on . The best previous deterministic trade-off, of Kadria, Roditty, Sidford, Vassilevska Williams, and Zwick [SODA'22], has stretch instead of at the same exponent (for even ) and requires integer edge lengths. In particular, for we obtain a deterministic 2-approximation in time for real edge lengths, whereas the deterministic algorithm of Ducoffe [SIDMA'21] for real lengths has stretch .
Our main technical idea is that a deterministic construction of the Thorup–Zwick hierarchy used by these algorithms may stop exploring as soon as it finds a cycle: the approximation analysis only needs clusters truncated at half the best cycle certificate found, so balls stopped in this way need not be hit. Together with a degree-weighted selection rule, this bounds the work of each level by its number of edges and stored ball entries. More generally, a ball need not be hit whenever the analysis only uses clusters up to a radius bounded by a certificate that the algorithm has already found.
*Department of Computer Science, Bar-Ilan University, Ramat Gan 5290002, Israel. E-mail: avi.kadria3@gmail.com.
1 Introduction
Let be an undirected graph with vertices, edges, and nonnegative real edge lengths. The girth of is the minimum length of a cycle in . Computing a shortest cycle is a fundamental problem that has been studied extensively, both in unweighted graphs (e.g., [IR78, AYZ97, YZ97, LL09, RV12, KRS 22]) and in weighted graphs (e.g., [LL09, RV11, RT13, Duc21, KRS 23]). In weighted graphs, computing the girth exactly is equivalent to All-Pairs Shortest Paths under subcubic reductions [RV11, VW18], so research has focused on approximation. We say an algorithm has stretch if it returns a cycle of length at most .
Lingas and Lundell [LL09] presented a 2-approximation algorithm for integer lengths in [1, M] that runs in time. Roditty and Tov [RT13] improved the stretch to 4/3 in the same time. Ducoffe [Duc21] gave the first subquadratic approximation for weighted graphs: a 2-approximation in time for integer lengths in [1, M].
Kadria, Roditty, Sidford, Vassilevska Williams, and Zwick [KRS 22] gave the first trade-off, which is also the best known deterministic one: for every integer , a cycle of length at most can be found in time for integer lengths in [1, M].
Using randomization, this trade-off was improved in two steps. First, Kadria, Roditty, Sidford, Vassilevska Williams, and Zwick [KRS 23, KRS 26] improved the stretch to : for every integer , a cycle of length at most can be found in expected time. Then, Kadria, Roditty, and Vassilevska Williams [KRV26] extended this trade-off to stretch in expected time for every integer . The additive term is necessary, since in weighted graphs one needs to read the input even for an approximation.
Like the classic distance oracles of Thorup and Zwick [TZ05], these randomized algorithms sample a hierarchy of vertex sets , and random sampling guarantees that the clusters of this hierarchy, which the algorithms explore, have small expected total size. Their approximation analysis, however, applies to every nested hierarchy with the desired properties, so randomness is used only to bound the running time. The question is therefore whether the randomized running times can be matched deterministically, while keeping the same running time and stretch tradeoff.
Our results. In this paper, we answer this question in the affirmative: our algorithms are deterministic, achieve the same stretch, and match the expected running times for every constant . Formally, we prove the following two theorems.
Theorem 1. There is a deterministic algorithm that, given an integer and a simple undirected graph with nonnegative real edge lengths that contains a cycle, returns a simple cycle of length at most , where is the girth of . Its running time is
hides polylogarithmic factors, assuming ; larger values of only increase the stretch, since already for .
They also obtained stretch in time for real lengths.
In addition, he presented a -approximation in time for nonnegative real lengths.
Take a complete graph whose edges have a huge length , and reduce the lengths of the edges of some triangle to 1. An algorithm with stretch and must find all three edges of length 1, since every other cycle has length more than , and finding 3 needles among edges requires time.
| Algorithm | Stretch | Running time | Type | Lengths |
|---|---|---|---|---|
| deterministic | integers in | |||
| randomized | nonnegative reals | |||
| deterministic | nonnegative reals | |||
| Theorem 1 | deterministic | nonnegative reals | ||
| (odd ) | randomized | nonnegative reals | ||
| Theorem 2 | deterministic | nonnegative reals | ||
| deterministic | nonnegative reals |
Table 1: Weighted girth approximation; and are integers. For even , the second block is covered by the first with . The bounds of hold in expectation, and those of the deterministic algorithms in the worst case.
Theorem 2. There is a deterministic algorithm that, given an integer and a simple undirected graph with nonnegative real edge lengths that contains a cycle, returns a simple cycle of length at most , where is the girth of . Its running time is
Theorem 1 is the case of even of Theorem 2. We state it separately because its proof contains the core construction (Section 4.1 to Section 4.5); Section 4.6 then adapts the half-level construction of [KRV26] to obtain the odd values of .
For every constant , the bound of Theorem 1 matches the expected running time of . Similarly, the bound of Theorem 2 matches the bound of . For general , the term that depends on is the same, and the term that depends on is larger by a factor of , since each of the levels of our construction scans the edges with heap operations; this loss disappears for constant and when . Table 1 compares the bounds. Like the algorithms of , our algorithms only add and compare lengths, so they work for arbitrary nonnegative real lengths; unlike them, they use no hashing.
Techniques. The Thorup–Zwick hierarchy can be derandomized by computing, deterministically, a small set that hits a ball of nearest centers around every vertex [RTZ05, Yan26]. However, computing these balls by shortest-path explorations scans the adjacency list of a vertex once for every center in its ball, which multiplies the edge term by the ball size, about . For example, combining the derandomization of Yan [Yan26, Theorem 3] with the algorithm of gives time, which is instead of for and . The greedy schedule of Yan [Yan26], which grows the balls in rounds with doubling quotas, controls the sizes of the balls, and the cluster searches of explore clusters lazily. Neither of them, however, constructs the balls in a batch that can be interrupted and resumed. Our new ingredients are the following.
-
Truncation (Lemma 4). Given a cycle certificate of value , the cluster searches may stop at radius , so a ball need not be hit if a short cycle was already found.
-
Safe termination (Lemma 7). One batched exploration grows all balls. The first cycle it closes ends the current growth call and lowers the cutoff U/2 to at most the distance already explored; later rounds and levels continue with the smaller cutoff. Balls that stop early still contain everything the truncated analysis needs.
-
Lazy propagation (Section 4.4). Every propagation we process creates an entry, follows a shortest-path tree edge, or closes the cycle that ends the growth call. No propagation is processed twice, and a degree-weighted variant of Yan's selection rule makes the total degree of the growing balls drop geometrically.
Determinism and related work. The randomized algorithms always return a correct cycle, but bound their running time only in expectation; our bounds hold in the worst case, which is also what is needed when a girth approximation is used as a subroutine of another deterministic algorithm. Compared with the previous deterministic trade-off [KRS 22], we improve the stretch from to at the same exponent, for nonnegative real lengths. Sampling-based shortest-path algorithms have been derandomized for distance oracles and spanners [RTZ05, Yan26], single-source shortest paths [Yan26], and diameter approximation [KRQV26]. Unlike these derandomizations, ours does not hit every ball, since a ball may stop at a radius set by a cycle certificate found during the construction.
Organization. Section 2 introduces notation and the previous tools we use. Section 3 gives an overview of our techniques. Section 4 proves Theorem 1 and, in Section 4.6, Theorem 2.
Let denote the shortest-path distance and a shortest path from to , and put , with . We write for a distance from to stored by an algorithm. Whenever vertices are compared by their distance from a vertex , ties are broken in favor of the smaller identifier.
We use the cluster graphs of . For an edge , let . The radius-r subgraph contains the vertices and edges at distance at most from ; uses strict inequalities.
Given a hierarchy , let be the closest vertex of to (with the smallest identifier among the closest ones), whenever . For , its cluster graph is defined by
We call an orientation satisfying this inequality a cluster orientation. Every shortest path from a to a vertex of lies in , and its edges, oriented away from a, are cluster orientations .
Cluster searches. Our main subroutine is ClusterOrCycle [KRS 26, Algorithm 2 and Lemma 5], which runs Spira's lazy variant of Dijkstra's algorithm [Spi73] on .
Lemma 1 ([KRS 26, Algorithm 2 and Lemma 5]). Let . The search ClusterOrCycle(a) extracts cluster orientations of from a heap in nondecreasing order of their key . Each discovered vertex inserts its cluster orientations into the heap one at a time in order of length: the first one when the vertex is discovered, and the next one when the previous one has been extracted. When an orientation is extracted, one of the following holds.
-
If w is new, then becomes a tree edge and .
-
If w is the predecessor of v, then the orientation is the reverse of a tree edge and is skipped.
-
Otherwise, the search stops and reports a certificate of value .
If the heap becomes empty, the search returns the shortest-path tree of . The search takes time.
An edge-access structure built during preprocessing produces the next cluster orientation in time . Case 2 is not stated explicitly in ; we add it so that the reverse of a tree edge is not reported as a cycle.
Algorithm Cycle. The algorithm Cycle of samples the hierarchy, computes and by multi-source Dijkstra, runs ClusterOrCycle(a) for every vertex , and finally performs the edge-and-pivot checks: for every edge , in both orientations, and every nonempty , it considers the certificate of value for , whenever is a non-tree edge whose endpoints both lie in the tree of . It returns the best certificate found. Its only randomness is in the sampling of the hierarchy and in the hash tables that store distances.
We use the approximation analysis of in the following form. For a shortest cycle and , define the radii
In [KRS 26], the checks may also use the distances computed during initialization; Lemma 2 shows that the checks above suffice.
In both cases and for , since . The cycle , the girth , and the radii are used only in the analysis; the algorithms do not know . We call the cluster search for good if
(C1) it reports a certificate of value at most , or
(C2) it returns a predecessor tree rooted at that contains, as an edge, every cluster orientation of with .
If (C2) holds and satisfies , then the edges of , oriented away from , are cluster orientations whose keys are the distances of their heads, at most . Hence they all belong to , so contains and its root-to- distance is .
Lemma 2 (Approximation analysis of ). Fix any hierarchy and a shortest cycle . If every cluster search is good, then the certificates reported by the cluster searches and by the edge-and-pivot checks on the returned trees include one of value at most .
Proof. The proof of , Lemmas 6–9 and Corollaries 7.1 and 9.1] applies, with every use of , Lemma 5] replaced by (C1) and (C2). That proof shows, by induction on , that either some certificate has value at most , or a vertex of (if ) or an endpoint of a longest edge of (if ) is within distance of . Since , the first alternative must eventually hold.
[KRS 26, Lemma 5] is used only for the search from a center in the inductive step, where the relevant edges of have cluster orientations of key at most at [KRS 26, Lemmas 6 and 8]. If , these orientations form all of , so (C2) would put into the tree ; hence (C1) holds and gives a certificate of value at most . If , they form the path . If (C1) fails, then (C2) puts this path into , so is not a tree edge, and are exact by the remark above, and the edge-and-pivot check of at the pivot yields a certificate of value at most , as in [KRS 26, Lemma 8].
Cycle extraction. We use the standard cycle representation of . Let be a shortest-path predecessor tree rooted at , with root-to- distance , and let denote its unique tree path. A non-tree edge with both endpoints in defines, for , the simple cycle
The cycle Z can be extracted in time from the predecessor chains of u and v .
3 Technical overview
We describe the construction for Theorem 1.
The randomized algorithm. For a hierarchy , the bunch of a vertex consists of the centers of that are closer to than every center of , that is, the centers whose level-i cluster contains . By double counting, the total size of the level-i clusters is . Besides time for preprocessing and time for the edge-and-pivot checks, the running time of is times the total cluster size, which is in expectation if each center of is sampled into with probability .
Choosing a level deterministically. Fix . For every vertex , its ball is a list of the centers of nearest to , in order of distance. If contains a center of the next level , then . The greedy schedule of Yan [Yan26] chooses in rounds. In each round, it grows every unhit ball to a quota of centers, and greedily selects centers until at most a quarter of the full balls remain unhit. It then stops growing the hit balls and doubles . Starting with a quota of , it selects at most centers. Since the number of unhit balls drops by a factor of four whenever the quota doubles, the balls store entries in total. We use a weighted variant of this rule that also makes the total degree of the unhit balls drop by a factor of four.
The obstacle: growing the balls. Balls are grown by a simultaneous shortest-path exploration from all centers: an entry for center stored at vertex is propagated along the edges of . Propagating every entry along every edge costs , which can be .
We use cycles to avoid this. Suppose the entry of at is propagated along at distance , and already stores at distance . Then either is an edge of the shortest-path tree of , or this tree together with contains a cycle of length at most . Hence every propagation creates an entry, is one of at most two propagations along a tree edge per entry, or finds a cycle, and we stop the exploration at the first cycle. We use a lazy event queue that never touches an edge before it is needed and never processes an event twice. Together with the weighted selection rule, this bounds the cost of all rounds of a level by .
Truncation. Stopping at a cycle leaves balls that are neither full nor hit. Let be the smallest certificate value found so far. Our key observation (Lemma 4) is that if , the analysis of [KRS23] uses cluster information only up to distance from each center; if , the cycle found already suffices. It is therefore enough to bound the truncated bunches, consisting of the centers with ; dually, each cluster is explored only up to distance from its center (Figure 2).
A cycle found at distance gives , so the new cutoff is at most , and the exploration has already processed everything below it. Every ball that is still growing therefore contains all centers it needs and can be terminated without being hit. Balls that were already full continue in later rounds under the smaller cutoff. Terminated balls receive no new entries, but their entries are still propagated. We prove this in Lemma 7 (see Figure 1).
Completing the algorithm. We construct the levels one by one, sharing the best certificate among them; during the construction, U and the cutoff U/2 may decrease. We then fix the final value and run the cluster searches and edge-and-pivot checks of on the resulting
(a)

(b)

Figure 1: Illustration of safe termination. (a) The first vertex that does not store a is active, so the event is pending. (b) A cycle closed at gives , so the new cutoff 9/2 is at most .
hierarchy, with every cluster search truncated at . Each level takes time, which gives the running time .
Stretch 2k/3. The algorithm of [KRV26] for odd k differs in its first level, which is sampled with probability instead of and whose sets are computed explicitly. Since these sets are computed in full anyway, the first level can be chosen by Yan's schedule directly, without cycle detection; the remaining levels are constructed as above (see Section 4.6 for more details).
4 Deterministic girth approximation algorithm
In this section we prove Theorem 1, and in Section 4.6 we prove Theorem 2.
4.1 Truncating the cluster searches
For and , define the truncated bunch of a vertex and the truncated cluster of a center as the vertex sets
For , , and , the set is the vertex set of , illustrated in Figure 2. Double counting gives
Let ClusterOrCycleBounded(a, ) denote ClusterOrCycle(a) stopped before extracting an edge with key at least . The stopping value of the bounded run is the key of the cycle-closing edge if it reports a cycle, and otherwise (including when the cluster is exhausted).
Lemma 3 (Bounded cluster search). Let , , and let be the stopping value of ClusterOrCycleBounded( ). Then:
(B1) If a cycle is reported, its certificate value is at most .

Figure 2: Illustration of the truncated cluster of a: the tree returned by the search (thick) and the cutoff (dashed).
(B2) The tree returned by the search contains, as an edge, every cluster orientation with , and hence a shortest path to every with .
Moreover, the search takes
time.
Proof. If the edge closes a cycle, then and was discovered earlier, at a key of at most , so the certificate value is at most . This proves (B1).
An extracted orientation with key less than does not close a cycle, so it is a tree edge or the reverse of one. Suppose that some cluster orientation with is never extracted, and choose one, , with minimum key. Vertex is discovered: either , or the last edge of is a cluster orientation with the smaller key , which is therefore extracted. By Lemma 1, vertex inserts its cluster orientations in order of length, and those up to have keys at most . The search stops only when it extracts an orientation of key , when the heap minimum reaches , or when the heap is empty. Hence every orientation of up to is inserted and then extracted in turn, a contradiction. The second part of (B2) follows by the argument before Lemma 2.
For the running time, an edge extracted in orientation has key by Lemma 1, and . Hence every extracted edge and both of its endpoints lie in . Before stopping, only tree edges, at most one reverse tree edge per discovered vertex, and possibly one cycle-closing edge are extracted, and the heap holds at most one pending orientation per discovered vertex. Since every discovered vertex lies in , the bound (6) follows.
For a radius , we call the (bounded or unbounded) cluster search for -good if it satisfies (C1) or (C2) with in place of .
Corollary 3. If , then ClusterOrCycleBounded is -good.
Proof. Let be the stopping value. If , then , so the search reported a cycle, and by (B1) its certificate has value at most ; this is (C1). Otherwise , and by (B2) the returned tree contains every cluster orientation with ; this is (C2).
The bounded algorithm. Given a hierarchy and a cycle certificate of value (where , with no certificate, is allowed), let BoundedCycle denote algorithm Cycle with the following changes:
-
the initialization phase of Cycle uses the given sets instead of sampling them, and the best certificate is initialized to the given one;
-
every cluster search is ClusterOrCycleBounded(a, ), with the cutoff fixed even when better certificates are found, and the edge-and-pivot checks use the returned trees;
-
all hash tables are replaced by balanced search trees.
Lemma 4 (Truncation transfer). For every hierarchy and every cycle certificate of value (or ), algorithm BoundedCycle returns a cycle of length at most .
Proof. If , the given certificate suffices. Otherwise for every , by (1). Hence, by Corollary 3, every bounded search is good, and Lemma 2 yields a certificate of value at most .
4.2 Constructing one level
Fix the current level with . We must choose the next level so that is small and the truncated bunches have small total size, where is the certificate value at the end of the construction of the level.
Balls. Order the centers of A at a vertex v by the key
and let be the position of in this order. Every vertex stores a list of entries, called its ball. An entry records a center , a distance , and a pointer to a predecessor entry of at a neighbor of . The ball is exact if its centers are the first centers in the order , in this order, and for each entry. Since ties are broken by identifiers, an exact ball may contain only some of the centers at its largest distance. We identify with its set of centers when writing inclusions. Finally, the hit threshold of is
with value if .
Lemma 5 (One-level construction). Let , , and let be an integer. Given a cycle certificate of value (or with no certificate), a deterministic algorithm computes and a cycle certificate of value (none if ) such that
Its running time is .
Algorithm 1: One-level construction
Input: , budget , and a cycle certificate of value (possibly )
1 ; for all ; mark all balls live;
2 foreach do insert the root entry , with no predecessor, in ;
3 ; ;
4 while a live ball remains do
5 ;
6 Grow( ) (Algorithm 2), updating and the ball states;
7 is quota-paused}; ;
8 for all , where ;
;
9 while do
10 Choose maximizing , breaking ties by smaller identifier;
11 ;
12 Mark every with hit-terminated and remove it from ;
13 ;
14 return , and with its certificate if
The construction (Algorithm 1) proceeds in rounds . Round consists of one growth call with quota , followed by one selection phase. We use a weighted variant of the schedule of Yan [Yan26, Section 2, Algorithm 1] with , where the cost of a ball of size is : quotas double, and each selection phase hits balls greedily by the weights of Algorithm 1 until at most one eighth of their total weight remains unhit. This makes both the number and the total degree of the unhit balls drop by a factor of four (Lemma 6).
The root entry of is the first entry of , since and every other center has positive distance from . Root entries count toward the first quota.
Ball states. A ball is live until it is permanently terminated. During a growth call with quota b, a live ball is active if , and quota-paused if . Only active balls receive new entries; a quota-paused ball becomes active again when the quota increases, unless selection terminates it first.
A ball is permanently terminated in one of two ways. It is hit-terminated when selection chooses a center already in its stored ball, or when growth appends a selected center to it. It is cutoff-terminated when growth stops at the current cutoff. Figure 3 shows all transitions. In every state, the stored entries of a ball are still propagated to other vertices.
Properties of growth calls. Section 4.3 describes Grow and proves (Lemma 7) that it has the following properties.
(G1) Every ball is always exact.
(G2) Growth appends a center to only if , and it hit-terminates if . In particular, growth keeps every live ball disjoint from .

Figure 3: Ball states. Solid (blue) transitions happen during growth calls, and dashed (orange) ones between them.
(G3) Only active balls receive entries, and when a growth call returns, every live ball is quota-paused.
Lemma 6 (Selection). Assume , and let be the set of vertices whose balls are live at the start of round . Then and . Moreover, Algorithm 1 performs rounds and returns a set with , and when it terminates, the total number of stored entries satisfies
and all selection phases together take time.
Proof. We first show that every live ball satisfies . This holds initially since . Growth preserves it by (G2), and selection preserves it since it terminates every live ball that contains the newly selected center. Therefore, by (G1), every ball in consists of exactly centers of .
The number and the total degree of the live balls. Let be the set when the weights are assigned, so that , where . Since is connected and contains a cycle, every vertex has degree at least 1, and therefore whenever . The initial weight is . If , the selection phase is vacuous and the bounds below hold trivially, so we assume that , and hence .
Let be the set of balls of that are not hit when the selection phase ends, and let . By the definition of the weights, , where , that is,
By the stopping rule, . Both fractions in this identity are nonnegative, so each is at most , that is, and .
By (G3), every ball that is live after the growth call of round is quota-paused. Hence, the balls that are live at the start of round are exactly the balls of . Since , it follows that and . Since , we get that and , as required.
The number of selected centers. Consider the selection phase of round with , and let be the total weight of the balls that are not hit yet. If we sum, over all centers of , the weight of these balls that contain the center, we get . Therefore, some center has weight at least , and each greedy selection multiplies by at most . After selections, we have . Thus, the phase ends after at most selections, where the inequality follows from and . This adapts the analysis of Yan [Yan26] to weighted balls. Since , round makes fewer than selections.
Next, we consider the case that . In this case, a quota-paused ball contains all of , so it can exist only if , and then one selection hits all of . Hence, round is the last round whenever , and there are at most rounds. If every round has , the rounds make fewer than selections. Otherwise, the last round has and makes at most one selection. If , then round had , and since , we get , that is, . Moreover, the previous rounds made fewer than selections, so . If , we use . Therefore, , as required.
The number of entries and the selection time. Terminated balls keep their entries, which are counted in . At most balls are live at the start of round , and each of them stores at most entries when it is terminated in that round. By charging every ball to its termination round, we get that
where the last equality follows from , since .
The selection phase of round uses the incidence lists of the at most balls in and a max-heap that stores, for every center occurring in them, the total weight of the balls that contain it. When a ball is hit, we subtract its weight from all the centers it contains. The weights are integers of value . Each of the at most incidences is inserted and removed at most once in that round, so the round costs time. By the same geometric sum, all selection phases together cost time, as required.
4.3 Growing the balls
We describe a growth call (Algorithm 2) using a conceptual event queue; Section 4.4 implements this queue without materializing an event for every entry-edge pair.
During one growth call, and are fixed, while may decrease. For every stored entry of at and every oriented edge into an active vertex, the event queue contains the propagation event , with tail and head , unless it has already been processed in this or an earlier call of the current level. Its key is
Keys are compared lexicographically, like the keys ; the first coordinate of a key is its distance coordinate. Events are processed in increasing order of key, and ties are broken by the identifiers of the head and the tail.
Each entry-edge orientation is processed at most once in the whole level. Removing the events into a vertex that becomes inactive does not mark them processed, and if the vertex resumes in a later call, they return to the queue. Notice that the algorithm does not compute the hit thresholds. Instead, a vertex is hit-terminated when a selected center arrives at it.
Algorithm 2: Grow(A, R, b, U, L)
1 Mark each live ball active if and quota-paused otherwise; 2 the unprocessed propagation events for every stored entry of a at u and every edge with v active; 3 while and the minimum event of Q has distance coordinate less than U/2 do 4 Extract the minimum event , with key , from Q and mark it processed; 5 if then 6 Append a to with and predecessor the entry of a at u; 7 Add the events for all edges with w active; 8 if then 9 mark v hit-terminated and remove all events into v; 10 else if then mark v quota-paused and remove all events into v; 11 else if is not a tree edge of then 12 , and record the cycle Z of (2) as its certificate; 13 break; 14 Mark every still-active ball cutoff-terminated;
The predecessor pointers of the entries of a center a are never changed, and form a tree . When U is updated, the cycle Z is extracted immediately from the predecessor chains as in Section 2, in time, so that it remains available after the trees of the level are discarded.
Lemma 7 (Correctness of growth). Throughout Algorithm 1, (G1) holds, and for every center a the tree is rooted at a, spans the vertices that store a, and its root paths are shortest paths. Growth calls satisfy (G2) and (G3). Every update of U strictly decreases it and records a cycle of length at most the new value. When Algorithm 1 terminates,
Proof. Property (G3) holds by construction, since only active balls receive entries and the last step of Algorithm 2 cutoff-terminates all balls that are still active. We prove the remaining claims by induction on the steps of Algorithm 1. At each step, let
be the set of centers required at v, that is, the centers that lie below the cutoff and do not come after the nearest selected center at v. Notice that, because of the non-strict inequality, the nearest
Formally, an event has priority , compared lexicographically.
selected center is required whenever it lies below the cutoff.
Adding centers to lowers , and never increases, so can only shrink over time. Moreover, is a prefix of the order . Consequently, if is an exact ball that misses a member of , then the first center missing from also belongs to . We maintain the following three invariants:
(I) Every is an exact ball, and the predecessor path of each entry of a at v is a shortest path from a to v.
(II) Every permanently terminated vertex satisfies .
(III) Every live ball is disjoint from R.
The invariants hold initially, after the root entries are inserted. Since only shrinks and terminated balls receive no entries, a terminated vertex continues to satisfy (II) once it does. We first show a queue property.
No required entry is hidden. Let . By the triangle inequality and since identifiers break ties in the same way at and at , every center that strictly precedes at also strictly precedes at . Consequently,
For the second implication, notice that , and that a selected center that strictly precedes at would strictly precede at , which contradicts .
Suppose that is active and that has rank at most . Let be the first vertex of that does not store . Since the root stores , the vertex preceding on stores . By (II) and (11), is not permanently terminated. Moreover, is not quota-paused, since by (I) and since the rank of at is at most , a quota-paused ball at would contain . Hence, is active.
Next, we show that the event is pending. The event has not been processed in this call or in any earlier call of the current level, since processing it would have left stored at , either by inserting it or because it was already there, and entries are never deleted. By (I), its key is . We have therefore proved the following queue property:
An empty queue has minimum . The same argument applies at the start of a call, since the queue then contains every unprocessed event into an active vertex.
Accepting an entry, pausing, and hits. Consider a minimum propagation event with key , where and , and let be the first center missing from . By (I) and (III), no selected center strictly precedes at , and therefore . By (I) and the path through , we also have , and therefore . Thus, and . If , then (12) contradicts the minimality of . Hence, , which implies that , that , and that . This proves (G2).
Appending the entry preserves (I), and attaching it to its already stored predecessor extends by one vertex. If , then , so (III) is preserved, and pausing at quota changes no invariant. If , then , so all the centers required at are now stored, and hit-terminating preserves (II) and (III). Finally, processing a tree-edge duplicate changes no invariant.
Cutoff-termination and cycle updates. If the minimum event has distance coordinate at least , then any active vertex that misses a member of again has a first missing center of rank at most b. The distance of this center is less than , which contradicts (12). The same argument applies to an empty queue. Thus, all active vertices can be cutoff-terminated.
Next, consider a non-tree duplicate with distance coordinate , and let . By (I) and the triangle inequality, . By (2), the extracted cycle satisfies
Therefore, the new cutoff satisfies . Immediately before this minimum event is processed, (12) excludes any missing required center of distance less than at an active vertex. Hence, cutoff-termination after the update also preserves (II).
Selection and restarting. A ball that is terminated by selection contains the newly selected center c. By (III), it contains no earlier selected center, so c is the nearest selected center at v. By (I), the ball contains every center up to c, and therefore it satisfies (II). Since selection terminates every live ball that contains c, (III) is preserved. Increasing the quota changes no stored information. At the next call, the queue consists of the events that remain unprocessed, including the events into quota-paused vertices that resume, and the argument above reestablishes (12). Notice that an event that was removed earlier, because its head became quota-paused, may now be a non-tree duplicate. In this case it triggers a new cycle update, which is covered by the previous case and again strictly decreases U. Thus, (I)–(III) hold across all calls.
This completes the induction. At termination, every vertex is permanently terminated, so (II) holds for every vertex. Since , this proves (10), as required.
4.4 Implementation and running time
Constructing all events of Algorithm 2 explicitly would cost time. We now describe an implementation that avoids this cost. Write . For every oriented edge , we maintain the index of the first entry of that has not been processed along e yet. The index is set to 1 when the construction of the level starts, and it is never reset. It advances only when the event of entry along e is processed. Since the events along an edge are ordered by , only the first unprocessed event of the edge needs to be represented.
We group the edges with the same tail and the same index into buckets
We maintain each bucket as an indexed min-heap ordered by . If entry j of exists, we represent only the minimum edge of in the global queue, with the priority of its

Figure 4: Illustration of the buckets of u. Only the minimum edge of a bucket is represented, and only if entry j of exists.
propagation event. Otherwise, the bucket waits for entry j. Since later entries on an edge have no smaller keys, these representatives give exactly the minimum event of Algorithm 2. A new entry at u activates at most one waiting bucket, the one for its index, without scanning the adjacency list of u.
After processing from , we remove it from that bucket and refresh or delete the old representative. If remains active, we insert into . If entry exists, we insert or decrease the representative of that bucket as needed, and otherwise the bucket waits for that entry. Thus, processing an edge updates at most two bucket representatives (see Figure 4).
A growth call starts by scanning the adjacency lists of the active vertices and inserting their incoming edges into the buckets given by their saved indices. When a head becomes inactive, we remove its incoming edges using heap handles. We keep an explicit list of the live vertices. Bucket records are created when they are first touched, in a balanced search tree keyed by . Hence, no table over all pairs needs to be cleared, and all dictionaries are deterministic. The entries of each ball are stored in an append-only array, so entry j of is accessed in constant time, and a balanced search tree supports membership queries and entry lookups by center. Finally, in the comparison-addition model, the cutoff test is implemented as .
Proof of Lemma 5. By Lemma 7, growth calls satisfy (G1)–(G3). Therefore, Lemma 6 gives , rounds, , and the bounds on . By Lemma 7, we get that . Lemma 7 also shows that and that every finite value comes with a cycle.
Next, we bound the work over all growth calls of the level. The active vertices of round belong to , so inserting and removing incoming edges takes heap operations. Similarly, maintaining the list of live vertices takes time.
Every processed event either inserts an entry, or is a tree-edge duplicate, or closes a cycle. At most X events insert entries. The center trees have fewer than X edges in total, each edge has two orientations, and each orientation is processed at most once per level for its center. Therefore, at most 2X events are tree-edge duplicates. At most one event per call closes a cycle and ends the call, and the subsequent cycle extraction costs time. Each processed event and each new entry changes at most two bucket representatives, and all heaps and dictionaries take time per operation. Hence, all growth calls together take time, and selection takes time. Since and , we get the claimed running time of , as required.
4.5 Constructing the hierarchy and completing the algorithm
Algorithm 3 constructs the hierarchy level by level with Lemma 5, using a single global best certificate, and then runs BoundedCycle, which performs new cluster searches on the completed hierarchy; the balls and trees used to choose the levels are discarded. For no level is constructed, , and BoundedCycle is the unbounded algorithm on the hierarchy , .
Algorithm 3: Deterministic girth approximation
Input: Graph and an integer
1 with no certificate; ; ; for ;
2 for do
3 ;
4 if then break;
5 Apply Algorithm 1 to with and the current certificate; set and update ;
6 if then break;
7 ; ;
8 Run BoundedCycle on with the certificate of value ;
9 return the cycle of the best certificate
Lemma 8 (Hierarchy). The construction of the hierarchy in Algorithm 3 takes time. The hierarchy satisfies
Proof. At each constructed level, . If , then and , so Lemma 5 bounds the level-i truncated bunches by at that level's output value , in time . Since only decreases afterwards, , so these bunches only shrink. If , or if (then , also for where ), the level-i truncated bunches have total size at most . Levels after an empty level contribute nothing. Summing over the at most levels proves the claim.
Proof of Theorem 1. Lemma 4 gives the approximation guarantee. The hierarchy costs time by Lemma 8.
In BoundedCycle, the preprocessing computes and for every level by a single run of Dijkstra's algorithm from a dummy vertex joined to all of by edges of length 0, and builds the edge-access structure; this takes time. By Lemma 3, the search from takes time. Hence, by double counting and Lemma 8, all bounded cluster searches together take time. The edge-and-pivot checks cost time with deterministic dictionaries. For the certificates found by the final searches, we keep only a description of the best one and extract its cycle at the end in time. Substituting proves the running-time bound.
4.6 Stretch 2k/3 for every k
For even , Theorem 1 with parameter returns a cycle of length at most in time. In the rest of this section, is odd and .
The randomized algorithm. The algorithm of [KRV26, Algorithm 1] uses a hierarchy , where is sampled from with probability and is sampled from with probability for . Phase 1 runs, for every with , a Dijkstra-based procedure from in , in time; if contains a shortest cycle of through , it returns a cycle of length [KRV26, Section 2]. Phase 2 runs ClusterOrCycle(a) for every , and Phase 3 performs the edge-and-pivot checks. Randomness is used for hashing and to bound and the cluster sizes of levels in expectation.
Lemma 9 (First level). A set with , the sets for all , and Phase 1 on them can be computed deterministically in time.
Proof. First sort the adjacency lists by length, breaking ties by neighbor identifier, and build a balanced search tree of the edges indexed by their endpoints. This one-time preprocessing costs and accounts for the m term.
Apply Yan’s algorithm [Yan26, Algorithm 1 and Theorem 4] with and , growing exact balls of nearest vertices. On sorted adjacency lists, a ball of nearest vertices and their distances can be computed in time [CLR 14, Section 2]. Since quotas double while the number of unhit balls decreases by a factor of eight, the total time for these computations, including repeated growth requests, is . Yan’s theorem gives and final balls with , each containing a vertex of .
Thus . We extract in time as the set of vertices with . We obtain by looking up every pair of its vertices in the edge search tree, then run Phase 1 on each nonempty . Constructing these subgraphs and running Phase 1 costs in total. Adding preprocessing proves the claim.
The other levels. For , we construct from with Lemma 5 and , as in Algorithm 3, sharing the best certificate and stopping when or . Then . Let be the final certificate value and . We then run Phases 2 and 3 with every cluster search replaced by ClusterOrCycleBounded( ) and all hash tables replaced by balanced search trees.
Fix a shortest cycle . Let , and, if , let for a longest edge of . We write for if and for otherwise.
Lemma 10 (Odd k). Let , fix a hierarchy , and suppose that Phase 1 is run on the exact sets and that every cluster search for a center of level is -good for every . Then the certificates found by the three phases include one of value at most .
Proof. Let C be the shortest cycle fixed in Section 4.6, and let be as defined there. The analysis of [KRV26] has two steps.
(1) Either some certificate has value at most 2g, or [KRV26, Lemma 10 and the proofs of Lemmas 11 and 12]. This step uses Phase 1 and one cluster search at level 1, from for a vertex , with radius .
(2) For , either some certificate has value at most , or [KRV26, Claims 11.1 and 12.1]. These proofs are the inductive step in the proof of Lemma 2 with replaced by . They use only that one search at level is -good for if , and for if .
Suppose that no certificate has value at most . By (1), . By induction, for : if (2) gave a certificate at level , its value would be at most . Hence , contradicting . All radii used are at most , so the searches involved are -good by assumption.
It remains to prove (1) under our assumptions, since [KRV26, Lemma 10] relies on .
Let , and let be the farthest edge of from with , let be the shortest path along , and let be the other path along . If , then Phase 1 returns a cycle of length . Otherwise, consider the search from with radius . If , then directly , since in this case, so we may assume that .
Orient every edge of away from , as in [KRV26, Lemma 10]: orient each edge other than along a shortest path from , and orient as . By the triangle inequality, every such orientation has key
since is at most for the edges other than , and at most the length of one of the two paths for . If all these orientations are cluster orientations of , then (C2) would put all edges of into the tree , which is impossible, so (C1) gives a certificate of value at most . Otherwise, one of these orientations is not a cluster orientation, and this is the only property of the search that the remaining argument of [KRV26, Lemma 10] uses. It shows that , and hence that [KRV26, proofs of Lemmas 11 and 12].
Proof of Theorem 2 for odd . By Lemma 9, the first level and Phase 1 take time. As in the proof of Lemma 8, the truncated bunches of levels have total size , and their construction takes time. As in the proof of Theorem 1, Phases 2 and 3 take time, so the total time is .
If , the certificate of value suffices. Otherwise , and by Corollary 3, every search ClusterOrCycleBounded( ) is -good for every . Hence Lemma 10 gives a certificate of value at most .
Use of AI tools
We used AI assistants based on large language models in this research, in each case the latest models available in October 2026 under a standard individual paid plan. ChatGPT (OpenAI), Claude (Anthropic) and Gemini (Google) were used to edit, write and revise the paper, to fix typos and to improve clarity. All models were also used to check for possible issues with correctness, omissions from the literature review, and inaccurate citations of previous results. ChatGPT (OpenAI) was used to discuss the ideas and to better understand previous papers. Claude (Anthropic) was used to create the illustrations of the paper. The author verified all proofs and ideas in the paper, proofread the entire paper, and takes full responsibility for its content.
References
[AYZ97] Noga Alon, Raphy Yuster, and Uri Zwick. Finding and counting given length cycles. Algorithmica, 17:209–223, 1997.
[CLR 14] Shiri Chechik, Daniel H. Larkin, Liam Roditty, Grant Schoenebeck, Robert Endre Tarjan, and Virginia Vassilevska Williams. Better approximation algorithms for the graph diameter. In Chandra Chekuri, editor, Proceedings of the Twenty-Fifth Annual ACM-SIAM Symposium on Discrete Algorithms, SODA 2014, Portland, Oregon, USA, January 5-7, 2014, pages 1041–1052. SIAM, 2014.
[Duc21] Guillaume Ducoffe. Faster approximation algorithms for computing shortest cycles on weighted graphs. SIAM J. Discret. Math., 35(2):953–969, 2021.
[IR78] Alon Itai and Michael Rodeh. Finding a minimum circuit in a graph. SIAM J. Comput., 7(4):413–423, 1978.
[KRQV26] Yael Kirkpatrick, Liam Roditty, Richard Qi, and Virginia Vassilevska Williams. New diameter approximations via distance oracle techniques, 2026.
[KRS 22] Avi Kadria, Liam Roditty, Aaron Sidford, Virginia Vassilevska Williams, and Uri Zwick. Algorithmic trade-offs for girth approximation in undirected graphs. In Proceedings of the 2022 Annual ACM-SIAM Symposium on Discrete Algorithms (SODA 2022), pages 1471–1492, 2022.
[KRS 23] Avi Kadria, Liam Roditty, Aaron Sidford, Virginia Vassilevska Williams, and Uri Zwick. Improved girth approximation in weighted undirected graphs. In Proceedings of the 2023 Annual ACM-SIAM Symposium on Discrete Algorithms (SODA), pages 2242–2255. SIAM, 2023.
[KRS 26] Avi Kadria, Liam Roditty, Aaron Sidford, Virginia Vassilevska Williams, and Uri Zwick. Improved girth approximation in weighted undirected graphs. SIAM Journal on Computing, 55(4):560–577, 2026.
[KRV26] Avi Kadria, Liam Roditty, and Virginia Vassilevska Williams. Tighter bounds for weighted and unweighted shortest cycle approximation. In 34th Annual European Symposium on Algorithms (ESA 2026), volume 388 of Leibniz International Proceedings in
Informatics (LIPIcs), pages 82:1–82:20. Schloss Dagstuhl – Leibniz-Zentrum für Informatik, 2026.
[LL09] Andrzej Lingas and Eva-Marta Lundell. Efficient approximation algorithms for shortest cycles in undirected graphs. Inf. Process. Lett., 109(10):493–498, 2009.
[RT13] Liam Roditty and Roei Tov. Approximating the girth. ACM Trans. Algorithms, 9(2):15:1–15:13, 2013.
[RTZ05] Liam Roditty, Mikkel Thorup, and Uri Zwick. Deterministic constructions of approximate distance oracles and spanners. In Luís Caires, Giuseppe F. Italiano, Luís Monteiro, Catuscia Palamidessi, and Moti Yung, editors, Automata, Languages and Programming, 32nd International Colloquium, ICALP 2005, Lisbon, Portugal, July 11-15, 2005, Proceedings, volume 3580 of Lecture Notes in Computer Science, pages 261–272. Springer, 2005.
[RV11] Liam Roditty and Virginia Vassilevska Williams. Minimum weight cycles and triangles: Equivalences and algorithms. In Rafail Ostrovsky, editor, IEEE 52nd Annual Symposium on Foundations of Computer Science, FOCS 2011, Palm Springs, CA, USA, October 22-25, 2011, pages 180–189. IEEE Computer Society, 2011.
[RV12] Liam Roditty and Virginia Vassilevska Williams. Subquadratic time approximation algorithms for the girth. In Yuval Rabani, editor, Proceedings of the Twenty-Third Annual ACM-SIAM Symposium on Discrete Algorithms, SODA 2012, Kyoto, Japan, January 17-19, 2012, pages 833–845. SIAM, 2012.
[Spi73] Philip M. Spira. A new algorithm for finding all shortest paths in a graph of positive arcs in average time . SIAM J. Comput., 2(1):28–32, 1973.
[TZ05] Mikkel Thorup and Uri Zwick. Approximate distance oracles. J. ACM, 52(1):1–24, 2005.
[VW18] Virginia Vassilevska Williams and R. Ryan Williams. Subcubic equivalences between path, matrix, and triangle problems. J. ACM, 65(5):27:1–27:38, 2018.
[Yan26] Shuyi Yan. Lossless derandomization for undirected single-source shortest paths and approximate distance oracles. In 2026 SIAM Symposium on Simplicity in Algorithms (SOSA), pages 404–412. SIAM, 2026.
[YZ97] Raphael Yuster and Uri Zwick. Finding even cycles even faster. SIAM J. Discret. Math., 10(2):209–222, 1997.