English

New algorithms for girth and cycle detection

Data Structures and Algorithms 2025-09-23 v2

Abstract

Let G=(V,E)G=(V,E) be an unweighted undirected graph with nn vertices and mm edges. Let gg be the girth of GG, that is, the length of a shortest cycle in GG. We present a randomized algorithm with a running time of O~(n1+1ε)\tilde{O}\big(\ell \cdot n^{1 + \frac{1}{\ell - \varepsilon}}\big) that returns a cycle of length at most 2g22εg2, 2\ell \left\lceil \frac{g}{2} \right\rceil - 2 \left\lfloor \varepsilon \left\lceil \frac{g}{2} \right\rceil \right\rfloor, where 2\ell \geq 2 is an integer and ε[0,1]\varepsilon \in [0,1], for every graph with g=polylog(n)g = polylog(n). Our algorithm generalizes an algorithm of Kadria \etal{} [SODA'22] that computes a cycle of length at most 4g22εg24\left\lceil \frac{g}{2} \right\rceil - 2\left\lfloor \varepsilon \left\lceil \frac{g}{2} \right\rceil \right\rfloor in O~(n1+12ε)\tilde{O}\big(n^{1 + \frac{1}{2 - \varepsilon}}\big) time. Kadria \etal{} presented also an algorithm that finds a cycle of length at most 2g2 2\ell \left\lceil \frac{g}{2} \right\rceil in O~(n1+1)\tilde{O}\big(n^{1 + \frac{1}{\ell}}\big) time, where \ell must be an integer. Our algorithm generalizes this algorithm, as well, by replacing the integer parameter \ell in the running time exponent with a real-valued parameter ε\ell - \varepsilon, thereby offering greater flexibility in parameter selection and enabling a broader spectrum of combinations between running times and cycle lengths. We also show that for sparse graphs a better tradeoff is possible, by presenting an O~(m1+1/(ε))\tilde{O}(\ell\cdot m^{1+1/(\ell-\varepsilon)}) time randomized algorithm that returns a cycle of length at most 2(g12)2(εg12+1)2\ell(\lfloor \frac{g-1}{2}\rfloor) - 2(\lfloor \varepsilon \lfloor \frac{g-1}{2}\rfloor \rfloor+1), where 3\ell\geq 3 is an integer and ε[0,1)\varepsilon\in [0,1), for every graph with g=polylog(n)g=polylog(n). To obtain our algorithms we develop several techniques and introduce a formal definition of hybrid cycle detection algorithms. [...]

Keywords

Cite

@article{arxiv.2507.02061,
  title  = {New algorithms for girth and cycle detection},
  author = {Liam Roditty and Plia Trabelsi},
  journal= {arXiv preprint arXiv:2507.02061},
  year   = {2025}
}
R2 v1 2026-07-01T03:43:51.267Z