Depth-first search

From Algowiki
Revision as of 17:03, 14 August 2014 by JanR (talk | contribs) (→‎Pseudocode)
Jump to navigation Jump to search

Definition

Pseudocode

DFS(G)

for each vertex uV [G]
do color[u] ← WHITE
π[u] ← NIL
time ← 0
do if color[u] == WHITE
then DFS-VISiT(u)

DFS-VISIT(u)

color[u] ← GRAY
timetime + 1
d[u] ← time
for each vAdj[u]