Space-Efficient Hierholzer: Eulerian Cycles in O(m) Time and O(n) Space

📅 2025-08-07
📈 Citations: 0
Influential: 0
📄 PDF
🤖 AI Summary
This paper addresses the space bottleneck in computing Eulerian circuits in large-scale (multi)graphs. We propose a space-efficient algorithm that reduces working memory from the conventional $O(m log n)$ bits to $O(n log m)$ bits on an $n$-vertex, $m$-edge graph, while retaining $O(m)$ time complexity. Our method introduces a novel non-recursive variant of Hierholzer’s algorithm that simulates recursion via an explicit stack, eliminating per-edge state markers and the implicit depth-first recursion stack. Instead, it relies solely on compact vertex-level data structures and bit-optimized memory management. To the best of our knowledge, this is the first algorithm achieving $O(m)$ time and $O(n)$ words—i.e., $O(n log m)$ bits—space for Eulerian circuit construction. The approach is particularly advantageous for dense graphs and high-multiplicity multigraphs. We provide a formal correctness proof verifying the algorithm’s soundness and termination.

Technology Category

Application Category

📝 Abstract
We describe a simple variant of Hierholzer's algorithm that finds an Eulerian cycle in a (multi)graph with $n$ vertices and $m$ edges using $mathrm{O}(n lg m)$ bits of working memory. This substantially improves the working space compared to standard implementations of Hierholzer's algorithm, which use $mathrm{O}(m lg n)$ bits of space. Our algorithm runs in linear time, like the classical versions, but avoids an $mathrm{O}(m)$-size stack of vertices or storing information for each edge. To our knowledge, this is the first linear-time algorithm to achieve this space bound, and the method is very easy to implement. The correctness argument, by contrast, is surprisingly subtle; we give a detailed formal proof. The space savings are particularly relevant for dense graphs or multigraphs with large edge multiplicities.
Problem

Research questions and friction points this paper is trying to address.

Finds Eulerian cycles with minimal memory usage
Improves space efficiency from O(m lg n) to O(n lg m)
Maintains linear time complexity without O(m)-size storage
Innovation

Methods, ideas, or system contributions that make the work stand out.

Space-efficient Hierholzer variant for Eulerian cycles
Uses O(n lg m) bits memory, improving O(m lg n)
Linear time, avoids O(m)-size stack or edge storage