.:: PSEUDOCODE ::. DFS(G) for each vertex u ∈ G.V u.color = WHITE u.π = NIL time = 0 for each vertex u ∈ G.V if u.color == WHITE DFS-VISIT(G,u) DFS-VISIT(G,u) time = time + 1 u.d = time u.color = GRAY for each v ∈ G.Adj[u] if v.color == WHITE v.π = u DFS-VISIT(G,v) u.color = BLACK time = time + 1 u.f = time
Many algorithms that work with directed graphs begin with such a decomposition. After decomposing the graph into strongly connected components, such algorithms run separately on each one and then combine the solutions according to the structure of connections among components. ALGORITHM STRONGLY-CONNECTED-COMPONENTS(G) call DFS(G) to compute finishing times u.f for each vertex u compute GT call DFS(GT), but in the main loop of DFS, consider the verteces in order of decreasing u.f (as computed in line 2) output the vertices of each tree in the depth-first forest formed in line 4 as a separate strongly connected component
PSEUDOCODE ARTICULATION-POINTS-DFS-VISIT(G,u) dfn = dfn + 1 u.d = u.low = dfn u.color = GRAY for each v ∈ G.Adj[u] if v.color == WHITE v.π = u DFS-VISIT(G,v) if u.d == 1 if G.Adj[u].size >= 2 AND v.low > u.d articPointsList.push_front(u) else if v.low >= u.d articPointsList.push_front(u) u.low = min(u.low, v.low) else if u.π != v u.low = min(u.low, v.d) u.color = BLACK
Comments
Post a Comment