Abstract
As the sizes of graphs grow rapidly, currently many real-world graphs can hardly be loaded in the main memory. It becomes a hot topic to compute depth-first search (DFS) results, i.e., depth-first order or DFS-Tree, on semi-external memory model. Semi-external algorithms assume the main memory could at least hold a spanning tree $T$ of a graph $G$, and gradually restructure $T$ into a DFS-Tree, which is non-trivial. In this paper, we present a comprehensive study of semi-external DFS problem. Based on our theoretical analysis of its main challenge, we introduce a new semi-external DFS algorithm, named EP-DFS, with a lightweight index $N^+$-index. Unlike traditional algorithms, we focus on addressing such complex problem efficiently not only with less I/Os, but also with simpler CPU calculation (implementation-friendly) and less random I/O accesses (key-to-efficiency). Extensive experimental evaluation is conducted on both synthetic and real graphs. The experimental results confirm that our EP-DFS algorithm significantly outperforms existing algorithms.
Introduction
Depth-First Search (DFS) is a fundamental graph algorithm used for tasks such as finding strongly connected components, topological sorting, and reachability testing. However, as modern datasets like web graphs and social networks scale to billions of edges, they frequently exceed the capacity of main memory (RAM). Standard DFS algorithms are inherently sequential and rely on random access, making them notoriously difficult to compute in external memory (disk-based) settings.
This research focuses on the semi-external memory model, where the system has sufficient RAM to store the graph's nodes and a spanning tree ($O(n)$), but must store the full edge set ($O(m)$) on disk. The core challenge in this model is the "chain reaction": updating a spanning tree to align with a true DFS-tree causes unpredictable changes in node ordering. Traditional semi-external algorithms often resort to repeated full-disk scans of the edge set, creating significant I/O bottlenecks.
Methodology: The EP-DFS Algorithm
The authors propose EP-DFS (Efficient Pruning DFS) to mitigate the chain reaction effect through three primary innovations: a specialized index, a node-freezing technique, and an optimized restructuring strategy.
Edge Classification and the $N^+$-index
To avoid redundant disk scans, EP-DFS utilizes a lightweight, compressed index called the $N^+$-index. This index stores only the edges that have the potential to alter the current tree structure—specifically, potential forward cross edges. By focusing on these critical edges and accessing them sequentially, the algorithm minimizes disk seek times and overall I/O volume.
Fixed Node Number (FNN) and Stability
A key theoretical contribution of the paper is the proof that node orders below a specific threshold, termed the Fixed Node Number (FNN), remain invariant during restructuring. EP-DFS tracks this FNN to "freeze" stable portions of the tree, effectively pruning the search space and preventing unnecessary recalculations for nodes whose positions are already finalized.
Iterative Restructuring Strategy
EP-DFS transforms an initial spanning tree into a DFS-tree through iterative updates. In each iteration, it loads batches of edges from the $N^+$-index to refine the tree. To accelerate convergence, the algorithm employs a rearrangement heuristic that orders the children of each node based on their subtree weights, helping the tree reach a DFS-compliant state more rapidly than arbitrary ordering.
Experimental Evaluation
The performance of EP-DFS was evaluated against state-of-the-art algorithms (EB-DFS and DC-DFS) using both synthetic (Erdos-Renyi, Scale-Free) and massive real-world datasets, such as the sk-2005 web crawl (50 million nodes, 1.9 billion edges).
Key Results
- Computational Speed: EP-DFS demonstrated order-of-magnitude improvements. For instance, on the
eu-2015-hostdataset, EP-DFS completed the search in 759 seconds, compared to 15,423 seconds for EB-DFS—a 20x speedup. - I/O Efficiency: The algorithm reduced I/O consumption by over 90% in several tests. On the same
eu-2015-hostgraph, EP-DFS required only 29 GB of I/O, while competitors required between 908 GB and 1.3 TB. - Scalability: EP-DFS was the only algorithm capable of processing the largest billion-edge graphs (
it-2004andsk-2005) within an 8-hour time limit, while other methods timed out.
Conclusion
EP-DFS provides a highly efficient solution for semi-external DFS by prioritizing sequential I/O and leveraging theoretical insights into node stability. While the algorithm shows exceptional empirical performance, establishing a tight asymptotic upper bound for the "chain reaction" remains an open challenge. Future research will focus on formal complexity analysis and further optimization of the index restructuring process for extremely dense graphs.
Summary updated