+ All Categories
Home > Documents > 1 Directed Acyclic Graph DAG – directed graph with no directed cycles.

1 Directed Acyclic Graph DAG – directed graph with no directed cycles.

Date post: 29-Mar-2015
Category:
Upload: skylar-minshall
View: 234 times
Download: 1 times
Share this document with a friend
Popular Tags:
28
1 Directed Acyclic Graph • DAG – directed graph with no directed cycles
Transcript
Page 1: 1 Directed Acyclic Graph DAG – directed graph with no directed cycles.

1

Directed Acyclic Graph

• DAG – directed graph with no directed cycles

Page 2: 1 Directed Acyclic Graph DAG – directed graph with no directed cycles.

2

Getting Dressed

Underwear Socks

ShoesPants

Belt

Shirt

Watch

Tie

Jacket

Page 3: 1 Directed Acyclic Graph DAG – directed graph with no directed cycles.

3

Topological Sort

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

Page 4: 1 Directed Acyclic Graph DAG – directed graph with no directed cycles.

4

Getting Dressed

Underwear Socks

ShoesPants

Belt

Shirt

Watch

Tie

Jacket

Socks Underwear Pants Shoes Watch Shirt Belt Tie Jacket

Page 5: 1 Directed Acyclic Graph DAG – directed graph with no directed cycles.

5

Topological Sort

Topological-Sort (G)1. call DFS(G) to compute finishing times f [v] for all v V2. as each vertex is finished, insert it onto the front of a linked list

3. return the linked list of vertices

Topological-Sort (G)1. call DFS(G) to compute finishing times f [v] for all v V2. as each vertex is finished, insert it onto the front of a linked list

3. return the linked list of vertices

Time: (|V|+|E|).

Page 6: 1 Directed Acyclic Graph DAG – directed graph with no directed cycles.

6

Getting Dressed

Underwear Socks

ShoesPants

Belt

Shirt

Watch

Tie

Jacket

1 |

Undiscovered

Active

Finished

Unfinished

Page 7: 1 Directed Acyclic Graph DAG – directed graph with no directed cycles.

7

Getting Dressed

Underwear Socks

ShoesPants

Belt

Shirt

Watch

Tie

Jacket

1 |

2 |

Undiscovered

Active

Finished

Unfinished

Page 8: 1 Directed Acyclic Graph DAG – directed graph with no directed cycles.

8

Getting Dressed

Underwear Socks

ShoesPants

Belt

Shirt

Watch

Tie

Jacket

1 |

2 |

3 |

Undiscovered

Active

Finished

Unfinished

Page 9: 1 Directed Acyclic Graph DAG – directed graph with no directed cycles.

9

Getting Dressed

Underwear Socks

ShoesPants

Belt

Shirt

Watch

Tie

Jacket

Jacket

1 |

2 |

3 | 4

Undiscovered

Active

Finished

Unfinished

Page 10: 1 Directed Acyclic Graph DAG – directed graph with no directed cycles.

10

Getting Dressed

Underwear Socks

ShoesPants

Belt

Shirt

Watch

Tie

Jacket

Tie Jacket

1 |

2 | 5

3 | 4

Undiscovered

Active

Finished

Unfinished

Page 11: 1 Directed Acyclic Graph DAG – directed graph with no directed cycles.

11

Getting Dressed

Underwear Socks

ShoesPants

Belt

Shirt

Watch

Tie

Jacket

Tie Jacket

6 |

1 |

2 | 5

3 | 4

Undiscovered

Active

Finished

Unfinished

Page 12: 1 Directed Acyclic Graph DAG – directed graph with no directed cycles.

12

Getting Dressed

Underwear Socks

ShoesPants

Belt

Shirt

Watch

Tie

Jacket

Belt Tie Jacket

6 | 7

1 |

2 | 5

3 | 4

Undiscovered

Active

Finished

Unfinished

Page 13: 1 Directed Acyclic Graph DAG – directed graph with no directed cycles.

13

Getting Dressed

Underwear Socks

ShoesPants

Belt

Shirt

Watch

Tie

Jacket

Shirt Belt Tie Jacket

6 | 7

1 | 8

2 | 5

3 | 4

Undiscovered

Active

Finished

Unfinished

Page 14: 1 Directed Acyclic Graph DAG – directed graph with no directed cycles.

14

Getting Dressed

Underwear Socks

ShoesPants

Belt

Shirt

Watch

Tie

Jacket

Shirt Belt Tie Jacket

6 | 7

1 | 8

2 | 5

3 | 4

9 |

Undiscovered

Active

Finished

Unfinished

Page 15: 1 Directed Acyclic Graph DAG – directed graph with no directed cycles.

15

Getting Dressed

Underwear Socks

ShoesPants

Belt

Shirt

Watch

Tie

Jacket

Watch Shirt Belt Tie Jacket

6 | 7

1 | 8

2 | 5

3 | 4

9 |10

Undiscovered

Active

Finished

Unfinished

Page 16: 1 Directed Acyclic Graph DAG – directed graph with no directed cycles.

16

Getting Dressed

Underwear Socks

ShoesPants

Belt

Shirt

Watch

Tie

Jacket

Watch Shirt Belt Tie Jacket

11 |

6 | 7

1 | 8

2 | 5

3 | 4

9 |10

Undiscovered

Active

Finished

Unfinished

Page 17: 1 Directed Acyclic Graph DAG – directed graph with no directed cycles.

17

Getting Dressed

Underwear Socks

ShoesPants

Belt

Shirt

Watch

Tie

Jacket

Watch Shirt Belt Tie Jacket

11 |

12 |

6 | 7

1 | 8

2 | 5

3 | 4

9 |10

Undiscovered

Active

Finished

Unfinished

Page 18: 1 Directed Acyclic Graph DAG – directed graph with no directed cycles.

18

Getting Dressed

Underwear Socks

ShoesPants

Belt

Shirt

Watch

Tie

Jacket

Watch Shirt Belt Tie Jacket

11 |

12 |

6 | 7

13 |

1 | 8

2 | 5

3 | 4

9 |10

Undiscovered

Active

Finished

Unfinished

Page 19: 1 Directed Acyclic Graph DAG – directed graph with no directed cycles.

19

Getting Dressed

Underwear Socks

ShoesPants

Belt

Shirt

Watch

Tie

Jacket

Shoes Watch Shirt Belt Tie Jacket

11 |

12 |

6 | 7

13 |14

1 | 8

2 | 5

3 | 4

9 |10

Undiscovered

Active

Finished

Unfinished

Page 20: 1 Directed Acyclic Graph DAG – directed graph with no directed cycles.

20

Getting Dressed

Underwear Socks

ShoesPants

Belt

Shirt

Watch

Tie

Jacket

Pants Shoes Watch Shirt Belt Tie Jacket

11 |

12 |15

6 | 7

13 |14

1 | 8

2 | 5

3 | 4

9 |10

Undiscovered

Active

Finished

Unfinished

Page 21: 1 Directed Acyclic Graph DAG – directed graph with no directed cycles.

21

Getting Dressed

Underwear Socks

ShoesPants

Belt

Shirt

Watch

Tie

Jacket

Underwear Pants Shoes Watch Shirt Belt Tie Jacket

11 | 16

12 |15

6 | 7

13 |14

1 | 8

2 | 5

3 | 4

9 |10

Undiscovered

Active

Finished

Unfinished

Page 22: 1 Directed Acyclic Graph DAG – directed graph with no directed cycles.

22

Getting Dressed

Underwear Socks

ShoesPants

Belt

Shirt

Watch

Tie

Jacket

Underwear Pants Shoes Watch Shirt Belt Tie Jacket

11 | 16

12 |15

6 | 7

13 |14

17 |

1 | 8

2 | 5

3 | 4

9 |10

Undiscovered

Active

Finished

Unfinished

Page 23: 1 Directed Acyclic Graph DAG – directed graph with no directed cycles.

23

Getting Dressed

Underwear Socks

ShoesPants

Belt

Shirt

Watch

Tie

Jacket

Socks Underwear Pants Shoes Watch Shirt Belt Tie Jacket

11 | 16

12 |15

6 | 7

13 |14

17 | 18

1 | 8

2 | 5

3 | 4

9 |10

Undiscovered

Active

Finished

Unfinished

Page 24: 1 Directed Acyclic Graph DAG – directed graph with no directed cycles.

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.

Strongly Connected

Not Strongly Connected

Page 25: 1 Directed Acyclic Graph DAG – directed graph with no directed cycles.

25

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

Strongly Connected Components

Page 26: 1 Directed Acyclic Graph DAG – directed graph with no directed cycles.

26

• 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

Page 27: 1 Directed Acyclic Graph DAG – directed graph with no directed cycles.

27

• GSCC has a topological ordering

Graph of Strongly Connected Components

Page 28: 1 Directed Acyclic Graph DAG – directed graph with no directed cycles.

28

1 |12 8 |11 13|16

14|155 | 63 | 4

2 | 7 9 |10

sourcevertex

d f

Tree edges Back edges Forward edges Cross edges

Kinds of Edges

B F

C

C

C

C

C

C


Recommended