Submitted:
05 April 2026
Posted:
09 April 2026
You are already at the latest version
Abstract
We present \textsc{Aegypti}, a hybrid algorithm for detecting a single triangle in an undirected graph \( G = (V, E) \) with \( n = |V| \) vertices and \( m = |E| \) edges. The algorithm operates in two phases. In the \emph{fast path}, a clique-constrained Union-Find structure (\textsc{FastCliqueUF}) streams over the edges and merges components only when the union remains a clique; the moment any component reaches size~\( \geq 3 \), a triangle witness is returned. Because components remain of size at most \( 2 \) until the detecting merge, each \textsc{Union} costs only \( \Oh(1) \) (bitset operations touch \( \Oh(k/\wordlen) \) blocks with \( k=O(1) \)). The fast path therefore runs in \( \Oh(n^2/\wordlen + m) \) time (dominated by initialisation), using packed \texttt{uint64} SIMD bitset operations; on triangle-rich graphs this reduces to \( \Oh(n^2/\wordlen) \) in practice and is \( \Oh(n^2) \) in the RAM model. If the fast path finds no triangle, a \emph{fallback} using adjacency-set intersections solves the problem in \( \Oh(m^{3/2}) \) time. The overall running time is therefore \( T(G) \;=\; \Oh\!\left( \frac{n^2}{\wordlen} + m^{3/2} \right) \) in the worst case. On triangle-rich graphs the fast path typically terminates after processing only a small fraction of the edges, achieving \( \Oh(n^2/\wordlen) \) time in practice; on triangle-free graphs the fallback dominates. For triangle-containing graphs, \( \Oh(n^2/\wordlen) \)is at most as large as \( \Oh(m^{3/2}) \) whenever \( m = \Omega(n^{4/3}) \) (the dense regime), and the constant-factor savings from SIMD make it substantially faster in practice. We prove correctness, analyse the complexity of each phase, and validate the algorithm on the full Second DIMACS Implementation Challenge benchmark suite, where \textsc{Aegypti} detects triangles in all tested instances in under \( 12 \)s.