07-ShortestPaths.pptx - Shortest Path Algorithms Reference Corman Leiserson Rivest Stein[CLRS Introduction to Algorithms MIT Press 2009 Chapter 24

07-ShortestPaths.pptx - Shortest Path Algorithms Reference...

This preview shows page 1 - 8 out of 18 pages.

Shortest Path Algorithms Reference: Corman, Leiserson, Rivest, Stein [CLRS], Introduction to Algorithms , MIT Press, 2009, Chapter 24
Image of page 1
Outline Basic concepts Bellman-Ford algorithm Relaxation Dijkstra’s algorithm
Image of page 2
Problem Statement Given an undirected Graph G = (V, E) V = Vertex set = {0, 1, 2, … n-1} E = Edge set = {(v i , v j ) where v i , v j V and an edge exists between v i and v j } w(v i , v j ) = non-negative weight of edge (v i , v j ) Path p is a sequences of distinct vertices (v 0 , v 1 , v 2 … v m-1 ) where (v i , v i+1 ) E A distance d = Σ i=0,m-2 w(v i , v i+1 ) Example: Path 0, 1, 3, 4: d=670 0 0 2 2 1 1 3 3 4 4 420 150 100 400 175 Find the minimum weight path from vertex s 0 to every other vertex
Image of page 3
Breadth First Search Revisited Breadth first search may not compute shortest path Idea: rather than ignoring marked vertices, check if a better (shorter) path has been found, update if it has 0 0 - - - - 0 1 10 1 3 1 1 10 10 0 0 Update 1, color gray Update 2, color gray 0 becomes black 0 is black 2 is gray No updates done 1 1 10 10 Incorrect distance computed Consider breadth first search, but link distance is any positive value (not necessarily 1) 2 10 1+3 < 10 Update node 2 to 4
Image of page 4
Bellman-Ford Algorithm: Relaxation Each vertex v stores: v.d=minimum weight path from source node s 0 computed so far (upper bound on length of shortest path) v.p=predecessor in minimum weight path computed so far Basic idea: progressively compute better and better shortest path upper bounds until no further improvement occurs Final state is referred to as a “fixed point” Algorithm Repeatedly scan through all edges in graph, updating d and p at each vertex by examining d at neighbor vertices
Image of page 5
Relaxation Step Check if shortest path to node v can be updated by using u as a predecessor v.d is current estimate of shortest path from s 0 to v u.d is current estimate of shortest path from s 0 to u If u.d+w < v.d The path through u is a better (shorter) path to v Update v to use the path through u Node u u.d Node u u.d Node v v.d Node v v.d Node s 0 Node s 0 w Repeatedly apply this relaxation step to all edges, until no further improvement (shorter paths) can be computed The result is we have computed the shortest path to all nodes
Image of page 6
Relaxation Algorithm // relaxation step for edge from vertex u to v Relax (u,v) if (u.d + w(u,v) < v.d) v.d = u.d + w(u,v);
Image of page 7
Image of page 8

You've reached the end of your free preview.

Want to read all 18 pages?

  • Fall '17
  • Richard Fujimoto

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern

Stuck? We have tutors online 24/7 who can help you get unstuck.
A+ icon
Ask Expert Tutors You can ask You can ask You can ask (will expire )
Answers in as fast as 15 minutes
A+ icon
Ask Expert Tutors