next up previous
Next: Topological Sorting Up: Easy Graph Problems Previous: Traversing a Graph

Depth-First Search


program177


program179

The following definitions for depth-first-search graphs were taken from the recommended text.[]

Tree edges
are edges in the depth-first forest tex2html_wrap_inline512. Edge (u,v) is a tree edge if v was discovered by exploring edge (u,v).
Back edges
are those edges (u,v) connecting a vertex u to an ancestor v in a depth-first tree. Self-loops are considered to be back edges.
Forward edges
are those nontree edges (u,v) connecting a vertex u to a descendant v in a depth-first tree.
Cross edges
are all other edges. They can go between vertices in the same depth-first tree, as long as one vertex is not an ancestor of the other, or they can go between vertices in different depth-first trees.

Depth-first-searches on undirected graphs can only have tree and back edges in their trees. Depth-first-searches on directed graphs can have all four types of edges.



Nitin Sharma
Wed Oct 8 17:46:14 PDT 1997