1 / 66

Lecture 33: Directed Graph Connectivity

CSC 213 – Large Scale Programming. Lecture 33: Directed Graph Connectivity. Today’s Goals. Examine new properties of DirectedGraph s What reaching & reachable mean for a Graph How humans go about computing these properties Algorithms for computers to compute these

lala
Download Presentation

Lecture 33: Directed Graph Connectivity

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CSC 213 – Large Scale Programming Lecture 33:Directed Graph Connectivity

  2. Today’s Goals • Examine new properties of DirectedGraphs • What reaching & reachablemean for a Graph • How humans go about computing these properties • Algorithms for computers to compute these • Examine what meant by DAG and why you care • Simple ways to develop schedules will be examined • How can algorithm tell when a schedule impossible

  3. Directed Graph • Only directed edges • Replace undirected edge with 2 directed edges • Relationships go in only one direction • One-way streets • Flights • Scheduling E D C B A

  4. Directed Graph • Only directed edges • Replace undirected edge with 2 directed edges • Relationships go in only one direction • One-way streets • Flights • Scheduling • Talking to your ex

  5. Directed Graph Properties e • Each edge goes one-way • (a,b)connectsatob • (a,b) does not connectb to a • Can discuss in-edges & out-edges • (a,b) is out-edge for a • (a,b) is in-edge for b • Adjacency-based Graph classes can change • Use 2 Sequences for adjacency-list vertices • Define source & target dimension in adjacency-matrix incidentEdges returns both in-edges & out-edges d c b a

  6. Reachability • e,a,dreachable from c e d c f a b

  7. Reachability • e,a,dreachable from c • creaches e e d c f a b

  8. Reachability • e,a,dreachable from c • creaches e • c reaches e & eincident upond,a e d c f a b

  9. Reachability • e,a,dreachable from c • creaches e • c reaches e & eis incident upond,a • d,aout-edges to c only e d c f a b

  10. Reachability • a,c,d,e,freachablefromb e d c f a b

  11. Reachability • a,c,d,e,freachablefromb • Path exists from b to every vertex e d c f a b

  12. Reachability • a,c,d,e,freachablefromb • Path exists from b to every vertex • Actually have multiple paths to most vertices e d c f a b

  13. Transitive Closure of G • Transitive closure ofGusually written as G* d e b c a G G*

  14. Transitive Closure of G • Transitive closure ofGusually written as G* • Identical vertex sets in G & G* • G & G* have different edge sets, however d e d e b b c c a a G G*

  15. Transitive Closure of G • Transitive closure ofGusually written as G* • Identical vertex sets in G & G* • G & G* have different edge sets, however • Edge in G*if targetreachable from sourceinG d e d e b b c c a a G G*

  16. Transitive Closure of G • Transitive closure ofGusually written as G* • Identical vertex sets in G & G* • G & G* have different edge sets, however • Edge in G*if targetreachable from sourceinG d e d e b b c c a a G G*

  17. Transitive Closure of G • Transitive closure ofGusually written as G* • Identical vertex sets in G & G* • G & G* have different edge sets, however • Edge in G*if targetreachable from sourceinG d e d e b b c c a a G G*

  18. Transitive Closure of G • Transitive closure ofGusually written as G* • Identical vertex sets in G & G* • G & G* have different edge sets, however • Edge in G*if targetreachable from sourceinG d e d e b b c c a a G G*

  19. Transitive Closure of G • Transitive closure ofGusually written as G* • Identical vertex sets in G & G* • G & G* have different edge sets, however • Edge in G*if targetreachable from sourceinG d e d e b b c c a a G G*

  20. Computing Transitive Closure • Use dynamic programming to compute this • This solution known as Floyd-Warshall Algorithm • But how fast is it?

  21. Floyd-Warshall’s Algorithm • Number G’s vertices from 1 to n • Algorithm will compute n directed graphs • Set G0=G to initialize this algorithm • Graph of transitive closure is end result (Gn = G*) • All ndirected graphs have same vertices • Gk contains all edges in Gk-1 (and Gk-2, Gk-3 ,…, G0) • Gk also has edge (vi,vj)if edges (vi,vk) & (vk,vj)in Gk-1 • Takes O(n3) time with adjacency matrix • Better to use “brute force” if few edges exist

  22. Floyd-Warshall’s Algorithm • Number G’s vertices from 1 to n • Algorithm willcompute n directed graphs • Set G0=G to initialize this algorithm • Graph of transitive closure is end result (Gn = G*) • All n directed graphs have same vertices • Gk contains all edges in Gk-1(and Gk-2, Gk-3 ,…, G0) • Gk also has edge (vi,vj)if edges (vi,vk) & (vk,vj)in Gk-1 • Takes O(n3) time with adjacency matrix • Better to use “brute force” if few edges exist

  23. Floyd-WarshallExample – G0 V7 V4 V6 V2 V3 V1 V5

  24. Floyd-WarshallExample – G1 V7 V4 V6 V2 V3 V1 V5

  25. Floyd-WarshallExample – G1 V7 V4 V6 V2 V3 V1 V5

  26. Floyd-WarshallExample – G1 V7 V4 V6 V2 V3 V1 V5

  27. Floyd-WarshallExample – G1 V7 V4 V6 V2 V3 V1 V5

  28. Floyd-WarshallExample – G1 V7 V4 V6 V2 V3 V1 V5

  29. Floyd-WarshallExample – G2 V7 V4 V6 V2 V3 V1 V5

  30. Floyd-WarshallExample – G2 V7 V4 V6 V2 V3 V1 V5

  31. Floyd-WarshallExample – G3 V7 V4 V6 V2 V3 V1 V5

  32. Floyd-WarshallExample – G3 V7 V4 V6 V2 V3 V1 V5

  33. Floyd-WarshallExample – G3 V7 V4 V6 V2 V3 V1 V5

  34. Floyd-WarshallExample – G3 V7 V4 V6 V2 V3 V1 V5

  35. Floyd-WarshallExample – G3 V7 V4 V6 V2 V3 V1 V5

  36. Floyd-WarshallExample – G4 V7 V4 V6 V2 V3 V1 V5

  37. Floyd-WarshallExample – G4 V7 V4 V6 V2 V3 V1 V5

  38. Floyd-WarshallExample – G4 V7 V4 V6 V2 V3 V1 V5

  39. Floyd-WarshallExample – G4 V7 V4 V6 V2 V3 V1 V5

  40. Floyd-WarshallExample – G4 V7 V4 V6 V2 V3 V1 V5

  41. Floyd-WarshallExample – G4 V7 V4 V6 V2 V3 V1 V5

  42. Floyd-WarshallExample – G5 V7 V4 V6 V2 V3 V1 V5

  43. Floyd-WarshallExample – G5 V7 V4 V6 V2 V3 V1 V5

  44. Floyd-WarshallExample – G5 V7 V4 V6 V2 V3 V1 V5

  45. Floyd-WarshallExample – G5 V7 V4 V6 V2 V3 V1 V5

  46. Floyd-WarshallExample – G6 V7 V4 V6 V2 V3 V1 V5

  47. Floyd-WarshallExample – G6 V7 V4 V6 V2 V3 V1 V5

  48. Floyd-WarshallExample – G7 V7 V4 V6 V2 V3 V1 V5

  49. Floyd-WarshallExample – G* V7 V4 V6 V2 V3 V1 V5

  50. Directed Acyclic Graph • Often called a DAG • Number & sort vertices • Topological order found • Eachedge (vi,vj) has i < j • Finds valid schedules… • …or proves cannot exist! d e b G (is a DAG) c a 5 4 d e 1 A valid ordering of G b 3 c 2 a

More Related