Hw. 7: Algorithm for finding strongly connected components.

advertisement
Hw. 6: Algorithm for finding
strongly connected components.
Original digraph
as drawn in our
book and in class:
Nodes:
Preorder
label
:
Postorder
label
Edges:
Solid: tree edge
Blue: back edge
Green: cross edge
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.
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.
The last depth first search, drawn with only the tree edges:
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.
Strongly Connected
Component
Strongly Connected
Component
Strongly Connected
Component
Strongly Connected
Component
To review:
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.
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