EP-BFS: Semi-External Breadth-First Search
- EP-BFS is a semi-external BFS algorithm for massive directed graphs that builds BFS trees using O(n) memory and compact in-memory sketches combined with sequential disk scans.
- It employs a threshold mechanism for edge filtering and iterative pruning to reduce I/O overhead and improve cache efficiency during in-memory reductions.
- Empirical evaluations demonstrate that EP-BFS significantly outperforms traditional methods by reducing runtime and disk I/O on large real-world datasets.
EP-BFS is a semi-external breadth-first search algorithm for massive directed, disk-resident graphs, introduced in "Efficient Semi-External Breadth-First Search" (Wan et al., 17 Jul 2025). It is designed to compute a BFS tree while using only main memory, with the explicit goal of keeping the in-memory sketch small, minimizing I/Os, and avoiding the heavy internal overhead associated with fully external BFS. The algorithm operates by maintaining a compact partial tree and edge sketch in RAM, scanning residual edges sequentially from disk, invoking an in-memory reduction procedure only when necessary, and progressively pruning vertices and edges whose final BFS positions have already been fixed (Wan et al., 17 Jul 2025).
1. Computational setting and motivation
EP-BFS is formulated in the semi-external memory model. The disk is divided into blocks of size , each I/O transfers one block between disk and RAM, and the main memory can hold at most elements. Unlike the fully external model, the semi-external model assumes , where and is a small constant, so memory is sufficient to hold at least a spanning tree of the graph. The graph is disk-resident, while RAM stores only a small sketch together with per-vertex attributes. The paper uses the minimum memory space requirement (MMSR) to denote the space used for this sketch and its node attributes; with 32-bit vertices and attributes, a “reasonable” MMSR is stated as roughly
that is, a few words per vertex plus edges (Wan et al., 17 Jul 2025).
The motivation is the inadequacy of both standard in-memory BFS and classical external-memory BFS on contemporary web and social graphs. Internal-memory BFS has time complexity 0 but requires the entire graph in RAM, which is infeasible for datasets such as WDC-2014 with 1.7 billion nodes and 64 billion edges, or eu-2015 with 1.07 billion nodes and 91.8 billion edges. Fully external BFS can reduce I/O asymptotically, but the best known algorithm for general directed graphs, EM-BFS, relies on a buffered repository tree and has I/O complexity
1
with substantial internal overhead. EP-BFS is positioned as the semi-external alternative: it retains 2-scale memory while pursuing substantially better practical performance on billion-scale directed graphs (Wan et al., 17 Jul 2025).
2. Graph-theoretic basis and precursor methods
The algorithm is built around a structural characterization of BFS trees. The graph is conceptually augmented with a dummy root 3 connected to all vertices, so disconnected components are handled by enqueuing children of 4 when the BFS queue becomes empty. For a spanning tree 5, the breadth-first order of a node 6 is denoted 7. The key notion is a V-BFS edge: an edge 8 such that 9, and if 0 is the parent of 1 in 2, then 3 and 4. The paper states that a spanning tree 5 of 6 is a BFS-tree if and only if there is no V-BFS edge in 7 as classified by 8. Semi-external BFS is therefore cast as the problem of repeatedly restructuring an arbitrary spanning tree until no V-BFS edges remain (Wan et al., 17 Jul 2025).
Two baseline semi-external algorithms are used as reference points. EE-BFS maintains only a spanning tree in memory and locally restructures it whenever a scanned edge is a V-BFS edge; its worst-case time is 9, where LLSP0 is the length of the longest simple path. EB-BFS stores a spanning tree together with a batch of up to 1 edges, runs an in-memory BFS on the union, and achieves time 2 and I/O 3. EP-BFS preserves the same small-memory regime as EB-BFS but modifies the sketch, the triggering logic for in-memory processing, and the pruning strategy to reduce practical cost substantially (Wan et al., 17 Jul 2025).
| Method | In-memory sketch | Stated behavior |
|---|---|---|
| EE-BFS | Spanning tree 4 | Edge-by-edge restructuring; worst-case 5 time |
| EB-BFS | 6 plus batch 7 of size up to 8 | Batch in-memory BFS; 9 time |
| EP-BFS | Forest 0, remaining tree edges on disk, batch 1 | Same asymptotic bound as EB-BFS, lower practical cost through thresholds, pruning, and cache-oriented layout |
3. Algorithmic organization
EP-BFS decomposes the current spanning tree into an in-memory forest 2 and a disk-resident set 3 of remaining tree edges. It also maintains an in-memory edge batch 4, with the capacity constraint 5. For each vertex 6, it stores two mutable attributes: 7, the current BFS index, and 8, the current parent. Additional structures include the array BON, which stores the BFS order of unpruned nodes and doubles as a queue during the in-memory reduction; Adj and ES, which represent adjacency lists with contiguous outgoing edges per vertex; and threshold values 9, 0, 1, and 2 (Wan et al., 17 Jul 2025).
The initialization phase scans the graph, partitions edges into sublists 3 of up to 4 edges each, builds an initial forest, and treats nodes of zero in-degree or zero out-degree specially via 5 and 6. When the in-memory sketch fills, a simple reduction recomputes a BFS forest of 7. A subsequent TreeReduce consolidates the structure into a spanning tree rooted at the dummy root and initializes the parent and BFS-order attributes. The main loop then repeatedly scans the active residual edge set 8, deciding for each edge whether it is irrelevant, should be retained for the next iteration, or should be inserted into the current batch 9 (Wan et al., 17 Jul 2025).
The threshold mechanism is the distinctive control device. Each batch 0 has a threshold 1, initialized to 2. When a scanned edge 3 is detected as a V-BFS edge with respect to the current tree, 4 is updated to 5, and the edge is inserted into 6. Edges are otherwise filtered according to the relation of their endpoints’ BFS orders to 7, 8, 9, and 0. This reduces both the number of edges admitted into the in-memory sketch and the number of times the in-memory procedure must be invoked (Wan et al., 17 Jul 2025).
The in-memory procedure itself is EP-Reduce. It performs BFS on 1, using BON as the queue and rebuilding 2 from the resulting parent pointers. Because outgoing edges of each vertex are stored contiguously in ES, scanning a node’s adjacency during this phase is cache-friendly. After each iteration, EP-BFS updates the global thresholds through the Find routine, prunes vertices whose positions are already fixed via vPrune, and shrinks the residual edge set via ErPrune. Over time the active graph 3 decreases, which lowers both scan volume and the number of future in-memory reductions. All disk I/O is sequential because the residual edge set is reorganized into adjacency lists on disk (Wan et al., 17 Jul 2025).
4. Correctness, complexity, and memory profile
The central correctness statement is Theorem 4.1 in the paper: EP-BFS returns the BFS tree correctly with at most LLSP4 iterations. The proof relates EP-BFS to repeated applications of reduced versions of EB-BFS and shows that the thresholding and pruning steps preserve the eventual BFS-tree while discarding only vertices and edges whose positions are already fixed. The dummy-root reconstruction step then restores the full tree on all vertices, including those with zero in-degree or zero out-degree (Wan et al., 17 Jul 2025).
The stated worst-case time complexity is
5
because EP-Reduce takes 6 time per invocation, there can be at most 7 invocations per iteration, and there are at most LLSP8 iterations. The I/O complexity is
9
since each iteration scans the residual edge set sequentially. Asymptotically this matches EB-BFS, but EP-BFS reduces the constant factors through fewer in-memory reductions, pruning of the residual graph, and contiguous adjacency storage (Wan et al., 17 Jul 2025).
The memory design is explicitly minimal for the semi-external setting. EP-BFS stores only two attributes per node, 0 and 1, together with at most 2 in-memory edges. For 3, the paper describes this as effectively 4 memory. On large graphs, the observed sketch size remained a small fraction of the full graph size: for eu-2015, the graph size is 683 GB and the EP-BFS sketch size 5 is 32.2 GB; for WDC-2014, the graph size is 480 GB and the sketch size is 51.7 GB; for Friendster, the graph size is 19.3 GB and the sketch size is 2.06 GB (Wan et al., 17 Jul 2025).
5. Empirical evaluation
The experimental study compares EP-BFS with EE-BFS, EB-BFS, and GridGraph on 14 real graphs and multiple synthetic graph families. The implementation uses Java 8 for EP-BFS, EE-BFS, and EB-BFS, and evaluates performance primarily on an HDD, with SSD experiments used to isolate the effect of device speed. The default parameter is 6, meaning that the in-memory sketch can hold 7 edges (Wan et al., 17 Jul 2025).
On real graphs, EP-BFS consistently reduces runtime and I/O relative to EB-BFS, and on the largest graphs it is often the only approach finishing within the 24-hour time limit. For example, on uk-2002, EB-BFS takes 4,097 seconds and 75.5 GB of I/O, whereas EP-BFS takes 138 seconds and 12.7 GB; on twitter-2010, EB-BFS takes 11,165 seconds and 175 GB of I/O, whereas EP-BFS takes 682 seconds and 40.8 GB. On uk-2014, clueweb12, gsh-2015, eu-2015, and WDC-2014, EB-BFS times out, while EP-BFS completes with runtimes from 25,535 to 73,526 seconds and I/O from 1,558 to 4,124 GB. The abstract summarizes the overall effect as “up to 10 times faster,” while individual datasets reported in the paper exhibit substantially larger gaps in some cases (Wan et al., 17 Jul 2025).
| Dataset | EB-BFS | EP-BFS |
|---|---|---|
| uk-2002 | 4,097 s; 75.5 GB I/O | 138 s; 12.7 GB I/O |
| twitter-2010 | 11,165 s; 175 GB I/O | 682 s; 40.8 GB I/O |
| WDC-2014 | timeout | 32,496 s; 1,558 GB I/O |
The paper attributes the improvement to three effects: fewer invocations of the in-memory process, lower per-iteration I/O due to graph pruning, and better cache behavior from contiguous adjacency storage. Random edge-sampling experiments on clueweb12 show that EP-BFS remains viable even when EB-BFS requires more than 20 hours on sparsified instances. In comparisons against GridGraph on subgraphs of twitter-2010, GridGraph times out for subgraphs with more than 3% of edges, whereas EP-BFS processes the full twitter-2010 graph in 682 seconds using about 1.26 GB memory. Synthetic experiments further show that EP-BFS scales better than EB-BFS as average degree and graph size increase, that its runtime is relatively stable across 8, and that HDD and SSD results are similar because the algorithm relies almost entirely on sequential I/O and is often CPU-bound rather than device-bound (Wan et al., 17 Jul 2025).
6. Terminology and related uses
The label “EP-BFS” is not uniform across graph-algorithm literature. In the semi-external memory setting, it specifically denotes the algorithm of "Efficient Semi-External Breadth-First Search" (Wan et al., 17 Jul 2025). In separate lines of work, closely related labels have been used for different concepts: reinforcement/backup fault-tolerant BFS structures in which some edges are reinforced and others serve as backups (Parter et al., 2015); dual-failure and multiple-source fault-tolerant BFS structures that preserve exact BFS distances under edge failures (Parter, 2015, Gupta et al., 2017); and elimination- or parameter-oriented BFS variants used to generate AT-free graph orders through domination-convexity tie-breaking (Beisegel, 2018).
This suggests that EP-BFS is best interpreted contextually rather than as a globally standardized term. In large-scale graph processing, the name refers to a semi-external BFS algorithm with 9-memory sketches, threshold-guided edge admission, iterative pruning, and sequential scans. In structural graph theory and survivable network design, similarly named constructions address different objectives entirely: exact distance preservation under failures, or search orders enforcing special convexity or elimination properties.