Hw. 6: Algorithm for finding strongly connected components.

6
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:

description

Hw. 6: Algorithm for finding strongly connected components. Original digraph as drawn in our book and in class:. Nodes:. :. Edges:. Preorder label. Postorder label. Solid: tree edge Blue: back edge Green: cross edge. Reverse arrows on original digraph:. - PowerPoint PPT Presentation

Transcript of Hw. 6: Algorithm for finding strongly connected components.

Page 1: Hw. 6: Algorithm for finding strongly connected components.

Hw. 6: Algorithm for finding strongly connected components.

Original digraphas drawn in our book and in class:

Preorderlabel

: Postorderlabel

Nodes:

Solid: tree edgeBlue: back edgeGreen: cross edge

Edges:

Page 2: Hw. 6: Algorithm for finding strongly connected components.

Reverse arrows on original digraph:

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

Page 3: Hw. 6: Algorithm for finding strongly connected components.

Depth First Search beginning at vertices with the highest Postorder value:

If we take a closelook at our newedges, we see that the tree edges of the DFS beginningat vertices with thehighest Postorder value form trees.This graph is in facta forest.

Page 4: Hw. 6: Algorithm for finding strongly connected components.

The last depth first search, drawn with only the tree edges:

Strongly ConnectedComponent

Strongly ConnectedComponent

Strongly ConnectedComponent

Strongly ConnectedComponent

When the last graph is redrawn using onlythe tree edges from thelast depth first search,the resulting graph is a forest. The trees that make up this forest arethe strongly connectedcomponents of the original graph.

Page 5: Hw. 6: Algorithm for finding strongly connected components.

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:

Page 6: Hw. 6: Algorithm for finding strongly connected components.

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.