Digraph Traversal
Same algorithms as for undirected graphs:
depthFirst(v):
- mark
v as visited
- for each
(v,w) ∈edges(G) do
if w has not been visited then
depthFirst(w)
breadth-first(v):
- enqueue
v
- while queue not empty do
dequeue v
if v not already visited then
mark v as visited
enqueue each vertex w adjacent to v
|