Download presentation
1
Directed Acyclic Graph
DAG – directed graph with no directed cycles
2
Getting Dressed Underwear Socks Watch Pants Shoes Shirt Belt Tie
Jacket
3
Topological Sort Linear ordering of the vertices of G, such that if (u,v)E, then u appears smewhere before v.
4
Getting Dressed Underwear Socks Watch Pants Shoes Shirt Belt Tie
Jacket Socks Underwear Pants Shoes Watch Shirt Belt Tie Jacket
5
Topological Sort Topological-Sort (G)
call DFS(G) to compute finishing times f [v] for all v V as each vertex is finished, insert it onto the front of a linked list return the linked list of vertices Time: (|V|+|E|).
6
Getting Dressed Underwear Socks Watch Pants Shoes Shirt Belt Tie
1 | Belt Undiscovered Tie Unfinished Active Finished Jacket
7
Getting Dressed Underwear Socks Watch Pants Shoes Shirt Belt Tie
1 | Belt Undiscovered Tie Unfinished 2 | Active Finished Jacket
8
Getting Dressed Underwear Socks Watch Pants Shoes Shirt Belt Tie
1 | Belt Undiscovered Tie Unfinished 2 | Active Finished Jacket 3 |
9
Getting Dressed Underwear Socks Watch Pants Shoes Shirt Belt Tie
1 | Belt Undiscovered Tie Unfinished 2 | Active Finished Jacket 3 | 4 Jacket
10
Getting Dressed Underwear Socks Watch Pants Shoes Shirt Belt Tie
1 | Belt Undiscovered Tie Unfinished 2 | 5 Active Finished Jacket 3 | 4 Tie Jacket
11
Getting Dressed Underwear Socks Watch Pants Shoes Shirt Belt Tie
1 | Belt Undiscovered 6 | Tie Unfinished 2 | 5 Active Finished Jacket 3 | 4 Tie Jacket
12
Getting Dressed Underwear Socks Watch Pants Shoes Shirt Belt Tie
1 | Belt Undiscovered 6 | 7 Tie Unfinished 2 | 5 Active Finished Jacket 3 | 4 Belt Tie Jacket
13
Getting Dressed Underwear Socks Watch Pants Shoes Shirt Belt Tie
1 | 8 Belt Undiscovered 6 | 7 Tie Unfinished 2 | 5 Active Finished Jacket 3 | 4 Shirt Belt Tie Jacket
14
Getting Dressed Underwear Socks Watch Pants Shoes Shirt Belt Tie
9 | Shirt 1 | 8 Belt Undiscovered 6 | 7 Tie Unfinished 2 | 5 Active Finished Jacket 3 | 4 Shirt Belt Tie Jacket
15
Getting Dressed Underwear Socks Watch Pants Shoes Shirt Belt Tie
9 |10 Shirt 1 | 8 Belt Undiscovered 6 | 7 Tie Unfinished 2 | 5 Active Finished Jacket 3 | 4 Watch Shirt Belt Tie Jacket
16
Getting Dressed Underwear Socks Watch Pants Shoes Shirt Belt Tie
11 | Watch Pants Shoes 9 |10 Shirt 1 | 8 Belt Undiscovered 6 | 7 Tie Unfinished 2 | 5 Active Finished Jacket 3 | 4 Watch Shirt Belt Tie Jacket
17
Getting Dressed Underwear Socks Watch Pants Shoes Shirt Belt Tie
11 | Watch 12 | Pants Shoes 9 |10 Shirt 1 | 8 Belt Undiscovered 6 | 7 Tie Unfinished 2 | 5 Active Finished Jacket 3 | 4 Watch Shirt Belt Tie Jacket
18
Getting Dressed Underwear Socks Watch Pants Shoes Shirt Belt Tie
11 | Watch 12 | Pants Shoes 13 | 9 |10 Shirt 1 | 8 Belt Undiscovered 6 | 7 Tie Unfinished 2 | 5 Active Finished Jacket 3 | 4 Watch Shirt Belt Tie Jacket
19
Getting Dressed Underwear Socks Watch Pants Shoes Shirt Belt Tie
11 | Watch 12 | Pants Shoes 13 |14 9 |10 Shirt 1 | 8 Belt Undiscovered 6 | 7 Tie Unfinished 2 | 5 Active Finished Jacket 3 | 4 Shoes Watch Shirt Belt Tie Jacket
20
Getting Dressed Underwear Socks Watch Pants Shoes Shirt Belt Tie
11 | Watch 12 |15 Pants Shoes 13 |14 9 |10 Shirt 1 | 8 Belt Undiscovered 6 | 7 Tie Unfinished 2 | 5 Active Finished Jacket 3 | 4 Pants Shoes Watch Shirt Belt Tie Jacket
21
Getting Dressed Underwear Socks Watch Pants Shoes Shirt Belt Tie
11 | 16 Watch 12 |15 Pants Shoes 13 |14 9 |10 Shirt 1 | 8 Belt Undiscovered 6 | 7 Tie Unfinished 2 | 5 Active Finished Jacket 3 | 4 Underwear Pants Shoes Watch Shirt Belt Tie Jacket
22
Getting Dressed Underwear Socks Watch Pants Shoes Shirt Belt Tie
11 | 16 17 | Watch 12 |15 Pants Shoes 13 |14 9 |10 Shirt 1 | 8 Belt Undiscovered 6 | 7 Tie Unfinished 2 | 5 Active Finished Jacket 3 | 4 Underwear Pants Shoes Watch Shirt Belt Tie Jacket
23
Getting Dressed Underwear Socks Watch Pants Shoes Shirt Belt Tie
11 | 16 17 | 18 Watch 12 |15 Pants Shoes 13 |14 9 |10 Shirt 1 | 8 Belt Undiscovered 6 | 7 Tie Unfinished 2 | 5 Active Finished Jacket 3 | 4 Socks Underwear Pants Shoes Watch Shirt Belt Tie Jacket
24
Strongly-Connected Graph G is strongly connected if, for every u and v in V, there is some path from u to v and some path from v to u. Not Strongly Connected Strongly Connected
25
Strongly Connected Components
A strongly connected component (SCC) of G is a maximal set of vertices C V such that for all u, v C, both u v and v u exist.
26
Graph of Strongly Connected Components
GSCC=(VSCC, ESCC): one vertex for each component (u, v) ESCC if there exists at least one directed edge from the corresponding components
27
Graph of Strongly Connected Components
GSCC has a topological ordering
28
Kinds of Edges d f 1 |12 8 |11 13|16 2 | 7 9 |10 3 | 4 5 | 6 14|15
source vertex d f 1 |12 8 |11 13|16 C C F 2 | 7 B 9 |10 C C 3 | 4 5 | 6 14|15 C C Tree edges Back edges Forward edges Cross edges
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.