Undirected Depth-First Search
It’s not just for trees
DFS(v)
if v marked then return;
mark v; #v := ++count;
for all edges (v,w) do DFS(w);
Main()
count := 0;
for all unmarked v do DFS(v);
back
edge
tree
edge
Previous slide
Next slide
Back to first slide
View graphic version