Depth-First search has a classic application: to decompose a graph into strong connected branches. Many algorithms for the direction graph begin with this step. (Algorithm introduction P338, feel concise and exquisite, share)
Strongly-connected-components (G)
1 call DFS (G) to compute finishing times F[u] for each vertex u
2 Compute GT
3 Call DFS (GT). But in the main loop of DFS, consider the vertices in order of decreasing f[u] (as computed in line 1)
4 output the vertices of the Depth-first forest formed in Line3 as a separate strongly connected component
More Wonderful content: http://www.bianceng.cnhttp://www.bianceng.cn/Programming/sjjg/
DFS (g): Depth traversal, GT for Figure G Transpose, F[u] is the second time stamp, when the vertex U is first discovered in the depth traversal, the first time stamp D[u] is recorded and the second time stamp is recorded when the adjacency table of U is checked, as shown in Figure 13/14, 13 is d[u[,14 f[u.
Lemma: Set C and C ' as two different strongly connected branches in the g= (v,e). Suppose that there is an edge (u,v) belonging to E, where u belongs to c,v belonging to C ', then f (c) >f (c ')
Corollary: To set C and C ' as two different strongly connected branches of the g= (v,e), assuming that there is an edge (u,v) belonging to ET, where u belongs to the c,v belongs to C ', then f (c) <f (c ')
To understand why Strongly-connected-components (G) can work properly? First, for a strongly connected branch C, assume that its completion time F (c) is the largest. The search begins at the beginning of a vertex x and accesses all the vertices in C, and, by inference, there is no edge from C to any other connected branch in the GT (should be f (C) the largest), so the search from X does not access vertices in any other branch. Then, by analogy, all the strongly connected branches are obtained.