,
Plia Trabelsi
Creative Commons Attribution 4.0 International license
Let G = (V,E) be an unweighted undirected graph with n vertices and m edges. Let g be the girth of G, that is, the length of a shortest cycle in G. We present a randomized algorithm with a running time of OΜ(π β
n^{1 + 1/(π-Ξ΅)}) that returns a cycle of length at most 2π βg/2β - 2 βΞ΅βg/2ββ, where π β₯ 2 is an integer and Ξ΅ β [0,1], for every graph with g = polylog(n).
Our algorithm generalizes an algorithm of Kadria et al. [SODA'22] that computes a cycle of length at most 4 βg/2β - 2 βΞ΅βg/2ββ in OΜ(n^{1 + 1/(2 - Ξ΅)}) time. Kadria et al. presented also an algorithm that finds a cycle of length at most 2π βg/2β in OΜ(n^{1 + 1/(π)}) time, where π must be an integer. Our algorithm generalizes this algorithm, as well, by replacing the integer parameter π in the running time exponent with a real-valued parameter π - Ξ΅, 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Μ(πβ
m^{1+ 1/(π-Ξ΅)}) time randomized algorithm that returns a cycle of length at most 2π(β(g-1)/2β) - 2(βΞ΅β(g-1)/2ββ+1), where π β₯ 3 is an integer and Ξ΅ β [0,1), for every graph with g = polylog(n).
To obtain our algorithms we develop several techniques and introduce a formal definition of hybrid cycle detection algorithms. Both may prove useful in broader contexts, including other cycle detection and approximation problems. Among our techniques is a new cycle searching technique, in which we search for a cycle from a given vertex and possibly all its neighbors in linear time. Using this technique together with more ideas we develop two hybrid algorithms. The first allows us to obtain an OΜ(m^{2-2/(βg/2β+1))-time, (+1)-approximation of g. The second is used to obtain our OΜ(πβ
n^{1+ 1/(π-Ξ΅)})-time and OΜ(πβ
m^{1+ 1/(π-Ξ΅)})-time approximation algorithms.
@InProceedings{roditty_et_al:LIPIcs.SWAT.2026.38,
author = {Roditty, Liam and Trabelsi, Plia},
title = {{New Algorithms for Girth and Cycle Detection}},
booktitle = {20th Scandinavian Symposium on Algorithm Theory (SWAT 2026)},
pages = {38:1--38:17},
series = {Leibniz International Proceedings in Informatics (LIPIcs)},
ISBN = {978-3-95977-421-5},
ISSN = {1868-8969},
year = {2026},
volume = {370},
editor = {Fraigniaud, Pierre},
publisher = {Schloss Dagstuhl -- Leibniz-Zentrum f{\"u}r Informatik},
address = {Dagstuhl, Germany},
URL = {https://drops.dagstuhl.de/entities/document/10.4230/LIPIcs.SWAT.2026.38},
URN = {urn:nbn:de:0030-drops-260742},
doi = {10.4230/LIPIcs.SWAT.2026.38},
annote = {Keywords: Graph algorithms, All pairs shortest path, Girth, Cycle approximation}
}