DFS(G) foreach node in G node.parent = null node.start = ∞ node.finish = ∞ node.color = UNEXPLORED; time = 1 foreach node in G if node.color == UNEXPLORED DFSVisit(G,node,time) DFS Visit(G, node) node.color = WORKING node.start = time++ for each x adjacent to node if x.color == UNEXPLORED x.parent = node DFSVisit(G,x,time) node.color = DONE node.finish=time++