Graphs Bfs Dfs
Graphs Bfs Dfs
It is so named because
Animation:
http://en.wikipedia.org/wiki/Image:Animated_BFS.gif
DFS-VISIT(u)
1 color[u] ← GRAY ▹White vertex u has just been discovered.
2 time ← time +1
3 d[u] time // record the discovery time
4 for each v ∈ Adj[u] ▹Explore edge(u, v).
5 do if color[v] = WHITE
6 then π[v] ← u // set the parent value
7 DFS-VISIT(v) // recursive call
8 color[u] BLACK ▹ Blacken u; it is finished.
9 f [u] ▹ time ← time +1
Everett
North Bend
Seattle