# Directed Acyclic Graph

## Presentation on theme: "Directed Acyclic Graph"— Presentation transcript:

Directed Acyclic Graph
DAG – directed graph with no directed cycles

Getting Dressed Underwear Socks Watch Pants Shoes Shirt Belt Tie
Jacket

Topological Sort Linear ordering of the vertices of G, such that if (u,v)E, then u appears smewhere before v.

Getting Dressed Underwear Socks Watch Pants Shoes Shirt Belt Tie
Jacket Socks Underwear Pants Shoes Watch Shirt Belt Tie Jacket

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|).

Getting Dressed Underwear Socks Watch Pants Shoes Shirt Belt Tie
1 | Belt Undiscovered Tie Unfinished Active Finished Jacket

Getting Dressed Underwear Socks Watch Pants Shoes Shirt Belt Tie
1 | Belt Undiscovered Tie Unfinished 2 | Active Finished Jacket

Getting Dressed Underwear Socks Watch Pants Shoes Shirt Belt Tie
1 | Belt Undiscovered Tie Unfinished 2 | Active Finished Jacket 3 |

Getting Dressed Underwear Socks Watch Pants Shoes Shirt Belt Tie
1 | Belt Undiscovered Tie Unfinished 2 | Active Finished Jacket 3 | 4 Jacket

Getting Dressed Underwear Socks Watch Pants Shoes Shirt Belt Tie
1 | Belt Undiscovered Tie Unfinished 2 | 5 Active Finished Jacket 3 | 4 Tie Jacket

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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.

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

Graph of Strongly Connected Components
GSCC has a topological ordering

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