Doing a
DepthFirstSearch in a [DiGraphs directed graph]
?, we get four kinds of edges:
A directed edge (U,W) is a:
- tree edge if, while visiting U, the DFS checks the edge (U,W) and W is not yet visited. Again, the tree edges form a tree, rooted at the start vertex (with edges directed away from the root).
- back edge if, while visiting U, the DFS checks the edge (U,W) and finds that W is an ancestor of U in the DFS tree. (The DFS has started exploring W but has not yet finished.)
- forward edge if, while visiting U, the DFS checks the edge (U,W) and finds that W is a descendant of U in the DFS tree. (And the DFS has already finished exploring W.)
- cross edge if, while visiting U, the DFS checks the edge (U,W) and finds that W is neither a descendant of U nor an ancestor in the DFS tree. (In this case also the DFS must have already finished exploring W.)
References