5.4 Depth First Traversal
Following the lead of Horowitz and Sahni (1978) [2], a distinction is made between a depth-first search (Sections 5.1 and 5.2) and a depth-first traversal. Given a graph , a series of depth-first searches that visit all the vertices in is referred to as a depth-first traversal. If is a connected graph, a single depth-first search produces a depth-first traversal. Otherwise, a depth-first traversal will discover all of the connected components of .
Algorithm 8 determines a depth-first traversal of . It assumes the buffer is used to communicate with the vertex list.
| first() |
| while |
| map() |
| next() |
| first() |
| while |
| if evaluate() is |
| dfs() |
| next() |
The time complexity of a depth-first traversal is linear if dfs is linear.