arXiv:2610.13452cs.DSOct 2026Cited by 1 paper on PaperVantage

Manuscript Offprint

arXiv:2610.13452

Deterministic Girth Approximation in Weighted Undirected Graphs

Avi Kadria

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 gg of an undirected graph with nn vertices, mm edges, and nonnegative real edge lengths. For every integer k≥2k \geq 2, our algorithm returns a cycle of length at most 2k3g\frac{2k}{3}g in O((m+n1+2/k)klog⁡n)O((m + n^{1+2/k})k \log n) worst-case time. For every constant kk, 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 O(min⁡{k,log⁡n})O(\min\{k, \log n\}) in the term that depends on mm. The best previous deterministic trade-off, of Kadria, Roditty, Sidford, Vassilevska Williams, and Zwick [SODA'22], has stretch kk instead of 2k3\frac{2k}{3} at the same exponent (for even kk) and requires integer edge lengths. In particular, for k=3k = 3 we obtain a deterministic 2-approximation in O((m+n5/3)log⁡n)O((m + n^{5/3}) \log n) time for real edge lengths, whereas the deterministic algorithm of Ducoffe [SIDMA'21] for real lengths has stretch 2+ε2 + \varepsilon.

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 G=(V,E,ℓ)G = (V, E, \ell) be an undirected graph with nn vertices, mm edges, and nonnegative real edge lengths. The girth gg of GG is the minimum length of a cycle in GG. 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 cc if it returns a cycle of length at most c⋅gc \cdot g.

Lingas and Lundell [LL09] presented a 2-approximation algorithm for integer lengths in [1, M] that runs in O~(n2log⁡M)\tilde{O}(n^2 \log M) time. 1^1 Roditty and Tov [RT13] improved the stretch to 4/3 in the same O~(n2log⁡M)\tilde{O}(n^2 \log M) time. 2^2 Ducoffe [Duc21] gave the first subquadratic approximation for weighted graphs: a 2-approximation in O~(n5/3 polylog M+m)\tilde{O}(n^{5/3} \text{ polylog } M + m) time for integer lengths in [1, M]. 3^3

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 κ≥1\kappa \geq 1, a cycle of length at most 2κg2\kappa g can be found in O((m+n1+1/κlog⁡n)log⁡(nM))O((m + n^{1+1/\kappa} \log n) \log(nM)) 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 4κ/34\kappa/3: for every integer κ≥1\kappa \geq 1, a cycle of length at most 4κg/34\kappa g/3 can be found in O((m+κn1+1/κ)log⁡n+κm)O((m + \kappa n^{1+1/\kappa}) \log n + \kappa m) expected time. Then, Kadria, Roditty, and Vassilevska Williams [KRV26] extended this trade-off to stretch 2k/32k/3 in O~(m+n1+2/k)\tilde{O}(m + n^{1+2/k}) expected time for every integer k≥2k \geq 2. The additive mm term is necessary, since in weighted graphs one needs to read the input even for an approximation. 4^{4}

Like the classic distance oracles of Thorup and Zwick [TZ05], these randomized algorithms sample a hierarchy of vertex sets V=A0⊇A1⊇⋯V = A_0 \supseteq A_1 \supseteq \cdots, 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 κ\kappa. Formally, we prove the following two theorems.

Theorem 1. There is a deterministic algorithm that, given an integer κ≥1\kappa \geq 1 and a simple undirected graph G=(V,E,ℓ)G = (V, E, \ell) with nonnegative real edge lengths that contains a cycle, returns a simple cycle of length at most 4κg/34\kappa g/3, where gg is the girth of GG. Its running time is

O((m+n1+1/κ)κlog⁡n).O\Big(\big(m+n^{1+1/\kappa}\big)\kappa\log n\Big).

1O~^{1}\tilde{O} hides polylogarithmic factors, assuming k=O(log⁡n)k = O(\log n); larger values of kk only increase the stretch, since n1+2/k=O(n)n^{1+2/k} = O(n) already for k≥2log⁡nk \geq 2\log n.

2^{2}They also obtained stretch 4/3+ε4/3 + \varepsilon in O~(n2/ε)\tilde{O}(n^{2}/\varepsilon) time for real lengths.

3^{3}In addition, he presented a (2+ε)(2+\varepsilon)-approximation in O~(n5/3 polylog(1/ε)+m)\tilde{O}(n^{5/3}\text{ polylog}(1/\varepsilon)+m) time for nonnegative real lengths.

4^{4}Take a complete graph whose edges have a huge length WW, and reduce the lengths of the edges of some triangle to 1. An algorithm with stretch cc and W>3cW > 3c must find all three edges of length 1, since every other cycle has length more than 3c3c, and finding 3 needles among Θ(n2)=Θ(m)\Theta(n^2) = \Theta(m) edges requires Ω(m)\Omega(m) time.

AlgorithmStretchRunning timeTypeLengths
[KRS+22]\left\lbrack {\mathrm{KRS}}^{+}{22}\right\rbrack2κ2\kappaO((m+n1+1/κlog⁡n)log⁡(nM))O((m+n^{1+1/\kappa}\log n)\log(nM))deterministicintegers in [1,M][1, M]
[KRS+23,KRS+26]\left\lbrack {\mathrm{KRS}}^{+}{23},\mathrm{KRS}^{+}{26}\right\rbrack4κ/34\kappa/3O((m+κn1+1/κ)log⁡n+κm)O((m+\kappa n^{1+1/\kappa})\log n+\kappa m)randomizednonnegative reals
[Yan26]+[KRS+23]\left\lbrack {\mathrm{Yan26}}\right\rbrack + \left\lbrack {\mathrm{KRS}}^{+}{23}\right\rbrack4κ/34\kappa/3O((m+nlog⁡n)κn1/κ)O((m+n\log n)\kappa n^{1/\kappa})deterministicnonnegative reals
Theorem 14κ/34\kappa/3O((m+n1+1/κ)κlog⁡n)O((m+n^{1+1/\kappa})\kappa\log n)deterministicnonnegative reals
[KRV26]\left\lbrack {\mathrm{KRV26}}\right\rbrack (odd kk)2k/32k/3O((m+kn1+2/k)log⁡n+km)O((m+kn^{1+2/k})\log n+km)randomizednonnegative reals
Theorem 22k/32k/3O((m+n1+2/k)klog⁡n)O((m+n^{1+2/k})k\log n)deterministicnonnegative reals
[Duc21](k=3)\left\lbrack {\mathrm{Duc21}}\right\rbrack (k=3)2+ε2+\varepsilonO~(m+n5/3polylog⁡(1/ε))\tilde{O}(m+n^{5/3}\operatorname{polylog}(1/\varepsilon))deterministicnonnegative reals

Table 1: Weighted girth approximation; κ≥1\kappa \geq 1 and k≥2k \geq 2 are integers. For even kk, the second block is covered by the first with κ=k/2\kappa = k/2. The bounds of [KRS+23,KRV26][\mathrm{KRS}^{+}23, \mathrm{KRV26}] hold in expectation, and those of the deterministic algorithms in the worst case.

Theorem 2. There is a deterministic algorithm that, given an integer k≥2k \ge 2 and a simple undirected graph G=(V,E,ℓ)G = (V, E, \ell) with nonnegative real edge lengths that contains a cycle, returns a simple cycle of length at most 2kg/32kg/3, where gg is the girth of GG. Its running time is

O((m+n1+2/k)klog⁡n).O\Big((m + n^{1+2/k})k \log n\Big).

Theorem 1 is the case of even k=2κk = 2\kappa 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 kk.

For every constant κ\kappa, the bound of Theorem 1 matches the expected running time O((m+κn1+1/κ)log⁡n+κm)O((m + \kappa n^{1+1/\kappa})\log n + \kappa m) of [KRS+23][\mathrm{KRS}^{+}23]. Similarly, the bound of Theorem 2 matches the bound O((m+κn1+2/k)log⁡n+km)O((m + \kappa n^{1+2/k})\log n + km) of [KRV26,Lemma 9][\mathrm{KRV26}, \mathrm{Lemma~9}]. For general κ\kappa, the term that depends on nn is the same, and the term that depends on mm is larger by a factor of O(min⁡{κ,log⁡n})O(\min\{\kappa, \log n\}), since each of the κ\kappa levels of our construction scans the edges with O(log⁡n)O(\log n) heap operations; this loss disappears for constant κ\kappa and when m=O(n1+1/κ)m = O(n^{1+1/\kappa}). Table 1 compares the bounds. Like the algorithms of [KRS+23,KRV26][\mathrm{KRS}^{+}23, \mathrm{KRV26}], 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 n1/κn^{1/\kappa}. For example, combining the derandomization of Yan [Yan26, Theorem 3] with the algorithm of [KRS+23][\mathrm{KRS}^{+}23] gives O((m+nlog⁡n)κn1/κ)O((m+n\log n)\kappa n^{1/\kappa}) time, which is Θ(n2)\Theta(n^2) instead of O~(n3/2)\tilde{O}(n^{3/2}) for m=n3/2m = n^{3/2} and κ=2\kappa = 2. 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 [KRS+23][\mathrm{KRS}^{+}23] 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.

  1. Truncation (Lemma 4). Given a cycle certificate of value UU, the cluster searches may stop at radius U/2U/2, so a ball need not be hit if a short cycle was already found.

  2. 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.

  3. 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 2κ2\kappa to 4κ/34\kappa/3 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.