Depth-First Search (DFS)
- Objective:
- Given a graph and a vertex S, discover every vertex in the
graph reachable from S.
- Strategy:
- As soon as a vertex is discovered, a new depth is explored (if
possible) even if not all vertices at previous depths have been discovered
- Side Effects:
-
- A depth-first tree is constructed
- However, the shortest-path distance from S to all vertices
is not guaranteed