Visit the nodes in DFS order.

Algorithm DFS(G)

  1. for each u ∈ V[G] do
  2.      visited[u] ← false
  3.      finished[u] ← false
  4. for each u ∈ V[G] do
  5.      if visited[u] = false
  6.           DFS-VISIT(G, u)

Algorithm DFS-VISIT(G, u)

  1. visited[u] ← true
  2. for each v ∈ Adj[u] do
  3.      if visited[v] = false then
  4.           DFS-VISIT(G, v)
  5. 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.