Visit the nodes in DFS order.
Algorithm DFS(G)
- for each u ∈ V[G] do
- visited[u] ← false
- finished[u] ← false
- for each u ∈ V[G] do
- if visited[u] = false
- DFS-VISIT(G, u)
Algorithm DFS-VISIT(G, u)
- visited[u] ← true
- for each v ∈ Adj[u] do
- if visited[v] = false then
- DFS-VISIT(G, v)
- finished[u] ← true
- Clicking on a node the first time marks the node visited.
- Clicking on a node the second time marks the node finished.
Some additional problems.