[Paper Review] Engineering DFS-Based Graph Algorithms
This paper presents optimization techniques for DFS-based graph algorithms, focusing on strongly connected components (SCC) computation. By overlaying node data structures and using an edge stack to reduce cache misses, the authors achieve 2x–3x speedups over LEDA and BOOST implementations, with similar gains for biconnected components algorithms.
Depth-first search (DFS) is the basis for many efficient graph algorithms. We introduce general techniques for the efficient implementation of DFS-based graph algorithms and exemplify them on three algorithms for computing strongly connected components. The techniques lead to speed-ups by a factor of two to three compared to the implementations provided by LEDA and BOOST. We have obtained similar speed-ups for biconnected components algorithms. We also compare the graph data types of LEDA and BOOST.
Motivation & Objective
- Address the performance gap between theoretical linear-time complexity and actual runtime in DFS-based graph algorithms.
- Identify implementation-level bottlenecks in existing libraries (LEDA and BOOST) that hinder optimal performance despite algorithmic efficiency.
- Develop and evaluate general-purpose engineering techniques to significantly improve the runtime of DFS-based algorithms on modern architectures.
- Demonstrate the effectiveness of these techniques on multiple algorithms, including SCC and biconnected components, to show broad applicability.
Proposed method
- Overlay node data structures to reduce memory footprint and minimize cache faults by combining multiple node labels (e.g., unvisited, visited, completed) into a single integer field.
- Replace random access to adjacency arrays with a stack-based edge traversal mechanism, reducing the number of random memory accesses from two per node to one.
- Implement non-recursive versions of DFS to reduce function call overhead, though this yields only marginal performance gains.
- Use static graph representations (single contiguous edge array) instead of dynamic linked lists to improve memory locality and reduce cache misses.
- Apply these optimizations systematically to three SCC algorithms: Tarjan’s, Cheriyan-Mehlhorn-Gabow, and Kosaraju-Sharir.
- Compare performance across different graph representations (LEDA static, LEDA dynamic, BGL) to isolate the impact of data structure choices.
Experimental results
Research questions
- RQ1How do low-level implementation choices such as memory layout and access patterns affect the runtime of DFS-based graph algorithms?
- RQ2To what extent can performance be improved by reorganizing node data storage to reduce cache misses?
- RQ3Can reducing the number of random memory accesses during DFS traversal lead to measurable performance gains on modern processors?
- RQ4How do different graph data structures (static vs. dynamic) influence the performance of DFS-based algorithms?
- RQ5Are the proposed optimization techniques generalizable beyond SCC algorithms to other DFS-based problems like biconnected components or topological sorting?
Key findings
- Overlaying node data structures reduced runtime by a factor of approximately two for both Tarjan’s and CMG algorithms.
- Introducing an edge stack reduced additional runtime by about 10% beyond the node data overlay, due to fewer cache faults during DFS traversal.
- The non-recursive implementation provided only marginal performance improvement, indicating that function call overhead is not the primary bottleneck.
- LEDA’s static graph representation outperformed both BGL and LEDA’s dynamic graphs due to better memory locality and reduced memory footprint.
- The tuned versions of Tarjan’s and CMG algorithms achieved near-optimal performance, with running times close to the lower bound set by a simple DFS scan.
- The same optimization techniques yielded similar speedups (2x–3x) for biconnected components algorithms, confirming their general applicability to DFS-based graph algorithms.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.