Presentation is loading. Please wait.

Presentation is loading. Please wait.

Hw. 6: Algorithm for finding strongly connected components. Original digraph as drawn in our book and in class: Preorder label : Postorder label Nodes:

Similar presentations


Presentation on theme: "Hw. 6: Algorithm for finding strongly connected components. Original digraph as drawn in our book and in class: Preorder label : Postorder label Nodes:"— Presentation transcript:

1 Hw. 6: Algorithm for finding strongly connected components. Original digraph as drawn in our book and in class: Preorder label : Postorder label Nodes: Solid: tree edge Blue: back edge Green: cross edge Edges:

2 Reverse arrows on original digraph: Note: This is the same digraph with all of the arrows reversed. To find the connected components in this digraph we must now do a Depth First Search, beginning at the vertices with the highest Postorder value.

3 Depth First Search beginning at vertices with the highest Postorder value: If we take a close look at our new edges, we see that the tree edges of the DFS beginning at vertices with the highest Postorder value form trees. This graph is in fact a forest.

4 The last depth first search, drawn with only the tree edges: Strongly Connected Component Strongly Connected Component Strongly Connected Component Strongly Connected Component When the last graph is redrawn using only the tree edges from the last depth first search, the resulting graph is a forest. The trees that make up this forest are the strongly connected components of the original graph.

5 An algorithm to find the strongly connected components of a digraph. 1. Do a Depth First Search on graph, label vertices in Post Order. 2. Compute reverse directed graph (switch direction of all arrows). 3. Do a DFS on the reversed graph, starting at vertices with highest Post Order label. Continue until all of the reversed graph has been searched. 4. The results of the DFS on the reversed graph results in a forest. The trees of this forest are the strongly connected components of the original graph. To review:

6 Hw. 6>> Carmen Frerichs (252a-ao) I used gw_dfs* and gw_basic_graph_algorithms* to create the graphs that I used in my presentation.


Download ppt "Hw. 6: Algorithm for finding strongly connected components. Original digraph as drawn in our book and in class: Preorder label : Postorder label Nodes:"

Similar presentations


Ads by Google