Skip to main content
QUICK REVIEW

[Paper Review] Space-Efficient DFS and Applications: Simpler, Leaner, Faster

Torben Hagerup|arXiv (Cornell University)|May 30, 2018
Algorithms and Data Compression2 references3 citations
TL;DR

This paper presents a simplified, space-efficient depth-first search (DFS) algorithm that runs in O(n + m) time using n + ∑_{v∈V≥3} ⌈log₂(dᵥ−1)⌉ + O(log n) bits, where dᵥ is the degree of vertex v. The method uses a novel stack compression technique with auxiliary data structures to track gray vertices and nontree edges, achieving optimal space usage while supporting efficient computation of biconnected components, bridges, and cut vertices.

ABSTRACT

The problem of space-efficient depth-first search (DFS) is reconsidered. A particularly simple and fast algorithm is presented that, on a directed or undirected input graph $G=(V,E)$ with $n$ vertices and $m$ edges, carries out a DFS in $O(n+m)$ time with $n+\sum_{v\in V_{\ge 3}}\lceil{\log_2(d_v-1)} ceil +O(\log n)\le n+m+O(\log n)$ bits of working memory, where $d_v$ is the (total) degree of $v$, for each $v\in V$, and $V_{\ge 3}=\{v\in V\mid d_v\ge 3\}$. A slightly more complicated variant of the algorithm works in the same time with at most $n+({4/5})m+O(\log n)$ bits. It is also shown that a DFS can be carried out in a graph with $n$ vertices and $m$ edges in $O(n+m\log^*\! n)$ time with $O(n)$ bits or in $O(n+m)$ time with either $O(n\log\log(4+{m/n}))$ bits or, for arbitrary integer $k\ge 1$, $O(n\log^{(k)}\! n)$ bits. These results among them subsume or improve most earlier results on space-efficient DFS. Some of the new time and space bounds are shown to extend to applications of DFS such as the computation of cut vertices, bridges, biconnected components and 2-edge-connected components in undirected graphs.

Motivation & Objective

  • To design a simpler, faster, and more space-efficient DFS algorithm for both directed and undirected graphs.
  • To reduce the working memory usage below O(n log n) bits while maintaining linear time complexity.
  • To extend the space-efficient DFS to applications such as computing biconnected components, bridges, and cut vertices.
  • To improve upon prior space bounds by leveraging degree-dependent space allocation and stack compression techniques.

Proposed method

  • The algorithm uses a compressed stack representation that stores only key vertices on a primary stack S′, reducing space usage based on vertex degrees.
  • An auxiliary stack Sᵤ maintains vertices that represent 'stripes' of the gray path, tracking whether their children are covered by nontree edges.
  • The algorithm employs eager restoration of stack segments: when a segment is restored, it propagates R-values and reinserts relevant vertices into Sᵤ to maintain correctness.
  • Positional information for vertices on S′ is maintained via static space allocation or rank-select structures, allowing O(n) total space and O(n/log n) time for initialization.
  • Nontree edge processing triggers stack pops from Sᵤ based on ancestor relationships, with state updates to R and R̄ to reflect coverage of subtrees.
  • The method uses a hybrid approach: storing only essential stack entries and using degree-dependent bit counts to minimize space, achieving near-optimal bounds.

Experimental results

Research questions

  • RQ1Can a DFS be implemented in O(n + m) time with space usage that depends on vertex degrees rather than just n?
  • RQ2How can stack restoration be optimized to reduce space without sacrificing time efficiency?
  • RQ3Can space-efficient DFS be extended to compute biconnected components, bridges, and cut vertices with the same time and space bounds?
  • RQ4Is it possible to achieve O(n + m) time with sublinear space in terms of m, especially for sparse graphs?

Key findings

  • The algorithm achieves O(n + m) time complexity with space usage bounded by n + ∑_{v∈V≥3} ⌈log₂(dᵥ−1)⌉ + O(log n) bits, which is significantly tighter than previous O(n log n) bounds.
  • A variant of the algorithm uses at most n + (4/5)m + O(log n) bits, improving space efficiency for dense graphs.
  • The method supports computation of biconnected components, bridges, and cut vertices in the same time and space bounds as the DFS itself.
  • For graphs with m = O(n), the space bound reduces to O(n), matching the best known density-independent bounds.
  • The algorithm improves upon prior work by combining stack compression with eager restoration, avoiding expensive full stack reconstruction.
  • The time and space bounds extend to computing 2-edge-connected components and strongly connected components, demonstrating broad applicability.

Better researchstarts right now

From reading papers to final review, dramatically reduce your research time.

No credit card · Free plan available

This review was created by AI and reviewed by human editors.