Strongly Connected Components

1,742 views 20 slides Sep 22, 2019
Slide 1
Slide 1 of 20
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20

About This Presentation

Strongly Connected Components


Slide Content

Strongly Connected Components
Prepared by
Md. Shafiuzzaman
Lecturer, Dept. of CSE, JUST

Md. Shafiuzzaman 2
Strongly Connected Components
Adirectedgraphisstronglyconnectedifthereisapathbetween
allpairsofvertices.
Astronglyconnectedcomponent(SCC)ofadirectedgraphisa
maximalstronglyconnectedsubgraph.

Md. Shafiuzzaman 3
Strongly Connected Components
astronglyconnectedcomponent(SCC)ofadirectedgraph
G(V,E)isamaximalsetofverticesUVsuchthat
–For each u,v U we have both uvand vu
i.e., u andvare mutually reachablefrom each other (uv)
Let G
T
(V,E
T
) be the transposeof G(V,E) where
E
T
{(u,v): (u,v) E}
–i.e., E
T
consists of edges of Gwith their directions reversed
Constructing G
T
from Gtakes O(V+E) time (adjacency list rep)
Note: Gand G
T
have the same SCCs (uv inGuv inG
T
)

Md. Shafiuzzaman 4
Strongly Connected Components
Algorithm
(1)Run DFS(G) to compute finishing times for all uV
(2)Compute G
T
(3)Call DFS(G
T
) processing vertices in main loop in
decreasing f[u] computed in Step (1)
(4)Output vertices of each DFTin DFFof Step (3)as a
separate SCC

Md. Shafiuzzaman 5
SCC: Examplea b c
e
d
f g h

Md. Shafiuzzaman 6
SCC: Examplea b c
e
d
f g h
1
1
(1)Run DFS(G) to compute finishing times for all uV

Md. Shafiuzzaman 7
SCC: Examplea b c
e
d
f g h
1
1
10
2734 56
89
(1)Run DFS(G) to compute finishing times for all uV

Md. Shafiuzzaman 8
SCC: Examplea b c
e
d
f g h
1
2
10
2734 56
8911
(1)Run DFS(G) to compute finishing times for all uV

Md. Shafiuzzaman 9
SCC: Examplea b c
e
d
f g h
1
2
10
2734 56
8916111413
1512
1
Vertices sorted according to the finishing times:
b, e, a, c, d, g, h, f 

Md. Shafiuzzaman 10
SCC: Examplea b c
e
d
f g h
(2)Compute G
T

Md. Shafiuzzaman 11
SCC: Examplea b c
e
d
f g h
(3) Call DFS(G
T
) processing vertices in main loop in
decreasing f[u] order:b, e, a, c, d, g, h, f 

Md. Shafiuzzaman 12
SCC: Examplea b c
e
d
f g h
r
1
=
(3) Call DFS(G
T
) processing vertices in main loop in
decreasing f[u] order:b, e, a, c, d, g, h, f 

Md. Shafiuzzaman 13
SCC: Examplea b c
e
d
f g h
r
1
=
(3) Call DFS(G
T
) processing vertices in main loop in
decreasing f[u] order:b, e, a, c, d, g, h, f 

Md. Shafiuzzaman 14
SCC: Examplea b c
e
d
f g h
r
1
= r
2
=
(3) Call DFS(G
T
) processing vertices in main loop in
decreasing f[u] order:b, e, a, c, d, g, h, f 

Md. Shafiuzzaman 15
SCC: Examplea b c
e
d
f g h
r
1
= r
2
=
(3) Call DFS(G
T
) processing vertices in main loop in
decreasing f[u] order:b, e, a, c, d, g, h, f 

Md. Shafiuzzaman 16
SCC: Examplea b c
e
d
f g h
r
1
= r
2
=
r
3
=
(3) Call DFS(G
T
) processing vertices in main loop in
decreasing f[u] order:b, e, a, c, d, g, h, f 

Md. Shafiuzzaman 17
SCC: Examplea b c
e
d
f g
h
r
1
= r
2
=
r
3
=
(3) Call DFS(G
T
) processing vertices in main loop in
decreasing f[u] order:b, e, a, c, d, g, h, f 

Md. Shafiuzzaman 18
SCC: Examplea b c
e
d
f g h
r
1
= r
2
=
r
3
= r
4
=
(3) Call DFS(G
T
) processing vertices in main loop in
decreasing f[u] order:b, e, a, c, d, g, h, f 

Md. Shafiuzzaman 19
SCC: Examplea b c
e
d
f g h
r
1
= r
2
=
r
3
= r
4
=
(4) Output vertices of each DFTin DFFas a separate SCC
C
b{b,a,e}
C
g{g,f} C
h{h}
C
c{c,d}

Md. Shafiuzzaman 20
SCC: Examplea b c
e
d
f g h
hf,g
c,d
a,b,e
Acyclic component
graph
C
b C
g
C
c
C
h