ArticleslgStudy

computer science

External memory graph traversal

External memory graph traversal is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand External memory graph traversal rather than just read about it. In short: 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.

External memory graph traversal — main illustration
External memory graph traversal — illustration

Key takeaways

  • External memory graph traversal belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect External memory graph traversal to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of External memory graph traversal from memory before moving on to harder problems.

Reference excerpt

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 G, Munagala and Ranade proposed the following external memory algorithm: Let L(t) denote the nodes in breadth-first search level t and let A(t):=N(L(t−1)) be the multi-set of neighbors of level t-1. For every t, L(t) can be constructed from A(t) by transforming it into a set and excluding previously visited nodes from it.

Create A(t) by accessing the adjacency list of every vertex in L(t−1). This step requires O(|L(t−1)|+|A(t)|/(D⋅B)) I/Os. Next A′(t) is created from A(t) by removing duplicates. This can be achieved via sorting of A(t), followed by a scan and compaction phase needing O(sort⁡(|A|)) I/Os. L(t):=A′(t)∖{L(t−1)∪L(t−2)} is calculated by a parallel scan over L(t−1) and L(t−2) and requires O((|A(t)|+|L(t−1)|+|L(t−2)|)/(D⋅B)) I/Os. The overall number of I/Os of this algorithm follows with consideration that ∑t|A(t)|=O(m) and ∑t|L(t)|=O(n) and is O(n+sort⁡(n+m)). 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 Si,0≤i≤K with small diameter. It further partitions the adjacency lists accordingly, by constructing an external file F=F0F1…FK−1, where Fi contains the adjacency list for all nodes in Si. The breadth-first search phase is similar to the MR algorithm. In addition the algorithm maintains a sorted external file H. This file is initialized with F0. Further, the nodes of any created breadth-first search level carry identifiers for the files Fi of their respective subgraphs Si. Instead of using random accesses to construct L(t) the file H is used.

Perform a parallel scan of sorted list L(t−1) and H. Extract the adjacency lists for nodes v∈L(t−1), that can be found in H. The adjacency lists for the remaining nodes that could not be found in H need to be fetched. A scan over L(t−1) yields the partition identifiers. After sorting and deletion of duplicates, the respective files Fi can be concatenated into a temporary file F'. The missing adjacency lists can be extracted from F' with a scan. Next, the remaining adjacency lists are merged into H with a single pass. A(t) is created by a simple scan. The partition information is attached to each node in A(t). The algorithm proceeds like the MR algorithm. Edges might be scanned more often in H, but unstructured I/Os in order to fetch adjacency lists are reduced. The overall number of I/Os for this algorithm is O(n⋅(n+m)D⋅B+sort⁡(n+m))

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 O((V+E/B)log2(V/B)+sort⁡(E)) 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:

insert(T, x), which adds item x to T and needs O(1/Blog2(N/B)) amortized I/Os. N is the number of items added to the BTR. extract(T, k), which reports and deletes from T all items with key k. It requires O(log2(N/B)+S/B) I/Os, where S is the size of the set returned by extract. 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 Ω(1) 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.

1 procedure BGVW-depth-first-search(G, v): 2 let S be a stack, P[] a priority queue for each node and D a BRT 3 S.push(v) 4 while S is not empty: 5 v := S.top() 6 if v is not marked: 7 mark(v) 8 extract all edges (v, x) from D, ∀x: P[v].delete(x) 9 if (u := P[v].delete-min()) is not null: 10 S.push(u) 11 else: 12 S.pop()

13 procedure mark(v) 14 put all edges (x, v) into D 15 ∀ (v, x): put x into P[v]

References

Worked examples

Example 1 — a first encounter with External memory graph traversal

Start with the simplest possible case. Write down what External memory graph traversal claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to External memory graph traversal before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about External memory graph traversal ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of External memory graph traversal

In research
External memory graph traversal appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses External memory graph traversal in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
External memory graph traversal is common in secondary-school and first-year university syllabi. It links to neighbouring topics External memory algorithms, Graph algorithms, so understanding it makes those chapters shorter.
In everyday life
Look for External memory graph traversal outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “External memory graph traversal” →

How to study External memory graph traversal in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what External memory graph traversal means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain External memory graph traversal out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is External memory graph traversal in simple terms?

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.

Why does External memory graph traversal matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study External memory graph traversal?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on External memory graph traversal.

Tags

  • External memory algorithms
  • Graph algorithms

Keep exploring