General Directed Graphs
Vertices a & b are strongly connected if path and .
SCC: Strongly Connected Component = maximal set of strongly connected vertices.
Metagraph on SCC’s: Vertex for each SCC. Edge if some & has edge .
Example:

Within Red boxes are SCC’s.
Metagraph on SCC’s:
This metagraph is a DAG.
Key: Every directed graph is a DAG on its SCC’s. Why? What if there is a cycle in SCC graph?
FALSE Conjecture: In a general directed graph vertex with lowest post # is in a sink SCC
Lemma: In a directed graph, the vertex with the highest post # lies in a source SCC.
Source is opposite of sink .
The reverse of : (FLIP EVERY EDGE)
Note that the SCC’s in will be the same as the SCC’s in
However, the DAG on SCC’s is flipped.
Source in = equal to sink in
Sink in = Source in
Final SCC Algorithm
- Given , construct
- Run DFS on
- Sort V by decreasing postorder number from step 2
- Take unvisited vertex with highest postorder number
- Run Explore() and label as a new SCC
- Repeat until all vertices are visited
For input G = (V, E)
Construct the Reversed Graph GR
Run DFS on GR and keep pre and post order number
Order V by decreasing post order number
run undirected connected components algorithm on G to find SCC's in G
DFS-cc(G):
For all vertices in V, set visited(v) = False
cc = 0
For all v in Vertices(Ordered by decreasing post order number)
If not visited(v)
then cc++
Explore(v)
Explore(z):
visited(z) = T
sccnum(z) = scc
for all edges in e:
if not visited(w) then explore(w)Lemma Proof
Lemma: In a directed graph, the vertex with the highest post # lies in a source SCC. Proof: Claim: If S & S’ are SCC’s & there is edge , , there is an edge

The max post # in S > than the max post # in S’
Only the claim has to be proved to prove the Lemma. If the claim is true then the SCC with the vertex with the greatest post order number then is MUST be true that it is the source SCC as no other SCC’s could point to it.
Proof of claim: Run DFS, take 1st vertex in that’s visited, call it Z.