Presentation is loading. Please wait.

Presentation is loading. Please wait.

Strongly Connected Components

Similar presentations


Presentation on theme: "Strongly Connected Components"— Presentation transcript:

1 Strongly Connected Components

2 Strongly Connected Components (SCC)
Directed Graph A set of nodes, such that every node is reachable from every other node in the SCC The assumption is that the SCC is the maximal set of such nodes – i.e. the largest sets where all nodes are reachable from each other. Typically we want to get a list of the SCCs Notice: if we replace an SCC by a single node, where edges to any node in the SCC are in-edges, and edges from any node in the SCC are out-edges, then we end up with a DAG

3 Computing Strongly Connected Components
Perform DFS like before. SCCs are identified when a back edge creates a cycle (and therefore connects everything in that subtree). Keep track of order visited, and “low” value, similar to bridges/articulation points Update Low only for Exploring (not Visited/Finished) vertices. Add each node to a stack When you finish a node where Num == Low, it marks the root of a SCC Pop nodes off the stack until you get that node off; those nodes are a SCC – can store them separately,

4 Low is lowest EXPLORING (not yet fully Visited) seen in that subgraph
1 2 d is when visited Low is lowest EXPLORING (not yet fully Visited) seen in that subgraph 6 3 5 8 9 7 4 3 Notice that the Low value is NOT updated to the previously node value, since the node it sees is already finished/visited, not still exploring

5 Alternative Approach To see if two components are in same SCC, check whether i->j and j->i are both possible Can compute transitive closure of the graph (use Floyd-Warshall, which we discuss in Shortest Path) Then, check for connectivity is trivial. But, pulling into lists of all SCCs takes O(n^2) time


Download ppt "Strongly Connected Components"

Similar presentations


Ads by Google