1 / 18

6.006- Introduction to Algorithms

6.006- Introduction to Algorithms. Lecture 14 Prof. Silvio Micali. Graphs. Undirected V={a,b,c,d} E={{a,b}, {a,c}, {b,c}, {b,d}, {c,d}}. Directed V = {a,b,c} E = {(a,c), (a,b) (b,c), (c,b)}. a. a. b. c. b. c. d. Computer Representation. Four representations with pros/cons

mignon
Download Presentation

6.006- Introduction to Algorithms

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. 6.006- Introduction to Algorithms Lecture14 Prof. Silvio Micali

  2. Graphs Undirected • V={a,b,c,d} • E={{a,b}, {a,c}, {b,c}, {b,d}, {c,d}} Directed • V = {a,b,c} • E = {(a,c), (a,b) (b,c), (c,b)} a a b c b c d

  3. Computer Representation Four representations with pros/cons Adjacency lists(of neighbors of each vertex) a c b

  4. a c b

  5. Breadth First Search • Start with vertex v • List all its neighbors (distance 1) • Then all their neighbors (distance 2) • Etc.

  6. Augmented Breadth First Search=Shortest Path Alg () Initially, is marked , all other vertices are marked 1. 2. Find all neighbors of at least one vertex marked . If none, STOP. 3. Mark all vertices found in (3) with . 4. Thm:Every vertex is marked with its distance form Complexity:

  7. BFS Tree Structure • Spanning Tree with Lots of Structural Information ? z a f s d x v c

  8. Depth First Search • Exploring a maze • From current vertex, move to another • Until you get stuck • Then backtrack till you find the first new possibility for exploration

  9. DFS 0. Mark all edges “unused”. For all Let and 1. 2. If has no unused edges, go to (4) 3. Choose an unused edge Mark used. If go to (2). Else and go to (1) 4. If HALT 5. and go to (2)

  10. DFS Tree Back Edge Tree Edge

  11. DFS Tree Directed Case Back Edge Forward Edge Tree Edge

  12. Connected Components An equivalence relation Linear with Good Counting!

  13. numbering of the vertices of a directed acyclic graph (DAG) such that Topological Sort if then

  14. Idea: Topological Reverse numbering of the vertices of a directed acyclic graph (DAG) such that if then

  15. More General Shortest Paths for a given node Undirected (Directed in recitation!) graphs with non-negative edge length Picture

  16. Dijstra’s Algorithm label. If , then there is a path from to of length , not necessarily minimum Set of temporarily labeled vertices Set of permanently labeled vertices 0. • do: • Choose with minimum label • &

  17. Analysis

  18. Cycles?

More Related