External memory graph traversal
External memory graph traversal is a type of graph traversal optimized for accessing externally stored memory. Background. Graph traversal is a subroutine in most graph algorithms. The goal of a graph traversal algorithm is to visit (and / or process) every node of a graph. Graph traversal algorithms, like breadth-first search and depth-first search, are analyzed using the von Neumann model, which assumes uniform memory access cost. This view neglects the fact, that for huge instances part of the graph resides on disk rather than internal memory. Since accessing the disk is magnitudes slower than  accessing internal memory, the need for efficient traversal of external memory exists. External memory model. For external memory algorithms the external memory model by Aggarwal and Vitter is used for analysis. A machine is specified by three parameters: "M", "B" and "D". "M" is the size of the internal memory, "B" is the block size of a disk and "D" is the number of parallel disks. The measure of performance for an external memory algorithm is the number of I/Os it performs. External memory breadth-first search. The breadth-first search algorithm starts at a root node and traverses  every node with depth one. If there are no more unvisited nodes at the current depth, nodes at a higher depth are traversed. Eventually, every node of the graph has been visited. Munagala and Ranade. For an undirected graph formula_1, Munagala and Ranade proposed the following external memory algorithm: Let formula_2 denote the nodes in breadth-first search level t and let formula_3 be the multi-set of neighbors of level t-1. For every t, formula_2 can be constructed from formula_5 by transforming it into a set and excluding previously visited nodes from it. The overall number of I/Os  of this algorithm follows with consideration that formula_17 and formula_18 and is formula_19. A visualization of the three described steps necessary to compute "L"("t") is depicted in the figure on the right. Mehlhorn and Meyer. Mehlhorn and Meyer proposed an algorithm that is based on the algorithm of Munagala and Ranade (MR) and improves their result. It consists of two phases. In the first phase the graph is preprocessed, the second phase performs a breadth-first search using the information gathered in phase one. During the preprocessing phase the graph is partitioned into disjointed subgraphs formula_20 with small diameter. It  further partitions the adjacency lists accordingly, by constructing an external file formula_21, where formula_22 contains the adjacency list for all nodes in formula_23. The breadth-first search phase is similar to the MR algorithm. In addition the algorithm maintains a sorted external file formula_24. This file is initialized with formula_25. Further, the nodes of any created breadth-first search level carry identifiers for the files formula_22 of their respective subgraphs formula_23. Instead of using random accesses to construct formula_2 the file formula_24 is used. Edges might be scanned more often in formula_24, but unstructured I/Os in order to fetch  adjacency lists are reduced. The overall number of I/Os for this algorithm is formula_43 External memory depth-first search. The depth-first search algorithm explores a graph along each branch as deep as possible, before backtracing. For "directed" graphs Buchsbaum, Goldwasser, Venkatasubramanian and Westbrook proposed an algorithm with formula_44 I/Os. This algorithm is based on a data structure called "buffered repository tree" (BRT). It stores a multi-set of items from an ordered universe. Items are identified by key. A BTR offers two operations: The algorithm simulates an internal depth-first search algorithm. A stack "S" of nodes  is hold. During an iteration for the node "v" on top of "S" push an unvisited neighbor onto "S" and iterate. If there are no unvisited neighbors pop "v". The difficulty is to determine whether a node is unvisited without doing formula_47 I/Os per edge. To do this for a node "v" incoming edges "(x,v)" are put into a BRT "D", when "v" is first discovered. Further, outgoing edges ("v","x") are put into a priority queue "P"("v"), keyed by the rank in the adjacency list. For vertex "u" on top of "S" all edges ("u","x") are extracted from  D. Such edges only exist if "x" has been discovered since the last time "u" was on top of "S" (or since the start of the algorithm if "u" is the first time on top of "S"). For every edge ("u","x") a delete("x") operation is performed on "P"("u"). Finally a "delete-min operation" on "P(u)" yields the next unvisited node. If "P"("u") is empty, "u" is popped from "S". Pseudocode for this algorithm is given below.