DFS(G) (1) foreach vertex u in V[G] (2) u.color = WHITE (3) u.parent = NIL (4) time = 1 (5) foreach vertex u in V[G] (6) if u.color = white (7) DFS-VISIT(u,G)
DFS-VISIT(u,G) (1) u.color = GREY (2) u.depth = time++ (3) foreach v Adjacient to u (4) if v.color = WHITE (5) v.parent = u (6) DFS-VISIT(v,G) (7) u.color = BLACK (8) u.finish = time++