Strongly Connected Components What's a Strongly Connected Component in a directed graph? A subgraph with a path from x to y and also a path from y to x for every pair of nodes x,y in the subgraph. Treat each strongly connected component as a meta-node. The resulting meta-graph is a Directed Acyclic Graph (DAG). List the strongly connected components in the directed graph. Draw the meta-graph (where each component is a meta-node). (graph3.pdf) V = { a, b, c, d, e, f } E = { (a,b), (a,d), (b,d), (b,e), (c,b), (c,f), (e,a), (e,d), (f,b), (f,e) } a---b---c | X | \ | d---e---f Finding the Components Suppose you use Depth-First Search to find the nodes in a component. Which component would you need to find first? the one that doesn't point to any other components How do you identify a node within this component? first node in a topological-sort of the reverse-edge graph What are the steps to find the strong components? 1. Create the graph with the edges reversed. 2. Run DFS-Forest on the reverse-edge graph. 3. Order the nodes by decreasing post-order number. 4. For each node n in the order from the last step, Run dfs(n) on the original-edge graph. 5. Nodes reachable by dfs(n) form a component. (remove last component before running next dfs) Finding the Components Example Show the steps of finding the components in the directed graph. 1. Draw the reverse-edge graph. 2. Draw the DFS-Forest for the reverse-edge graph. 3. Give the postorder numbers for the nodes in the reverse-edge graph. 4. Draw the DFS-Tree for each component in the order it is found. 5. Draw the meta-graph. (graph3.pdf) V = { a, b, c, d, e, f } E = { (a,b), (a,d), (b,d), (b,e), (c,b), (c,f), (e,a), (e,d), (f,b), (f,e) } a---b---c | X | \ | d---e---f Classwork You may work with a partner. Show the steps of finding the components in the directed graph. 1. Draw the reverse-edge graph. 2. Draw the DFS-Forest for the reverse-edge graph. 3. Give the postorder numbers for the nodes in the reverse-edge graph. 4. Draw the DFS-Tree for each component in the order it is found. 5. Draw the meta-graph. (graph2.pdf) V = { a, b, c, d, e } E = { (b,a), (b,c), (b,d), (b,e), (c,b), (d,c), (d,e), (e,a) } a---b---c \ / \ / e---d