Download - Lecture 39
![Page 1: Lecture 39](https://reader036.vdocuments.site/reader036/viewer/2022083006/56813b9d550346895da4d326/html5/thumbnails/1.jpg)
Lecture 39
CSE 331Dec 9, 2009
![Page 2: Lecture 39](https://reader036.vdocuments.site/reader036/viewer/2022083006/56813b9d550346895da4d326/html5/thumbnails/2.jpg)
Announcements
Please fill in the online feedback form
Sample final has been posted
Graded HW 9 on Friday
![Page 3: Lecture 39](https://reader036.vdocuments.site/reader036/viewer/2022083006/56813b9d550346895da4d326/html5/thumbnails/3.jpg)
Shortest Path Problem
Input: (Directed) Graph G=(V,E) and for every edge e has a cost ce (can be <0)
t in V
Output: Shortest path from every s to t
1 1
100
-1000
899
s t
Shortest path has cost negative
infinity
Shortest path has cost negative
infinity
Assume that G has no negative
cycle
Assume that G has no negative
cycle
![Page 4: Lecture 39](https://reader036.vdocuments.site/reader036/viewer/2022083006/56813b9d550346895da4d326/html5/thumbnails/4.jpg)
Recurrence Relation
OPT(i,v) = cost of shortest path from v to t with at most i edges
OPT(i,v) = min { OPT(i-1,v), min(v,w) in E { cv,w + OPT(i-1, w)} }
Path uses ≤ i-1 edgesPath uses ≤ i-1 edges Best path through all neighbors
Best path through all neighbors
![Page 5: Lecture 39](https://reader036.vdocuments.site/reader036/viewer/2022083006/56813b9d550346895da4d326/html5/thumbnails/5.jpg)
Some consequencesOPT(i,v) = shortest path from v to t with at most i edges
OPT(i,v) = min { OPT(i-1,v), min(v,w) in E { cv,w + OPT(i-1, w)} }
OPT(n-1,v) is shortest path cost between v and tOPT(n-1,v) is shortest path cost between v and t
Group talk time:How to compute the shortest path between s and t given all
OPT(i,v) values
Group talk time:How to compute the shortest path between s and t given all
OPT(i,v) values
![Page 6: Lecture 39](https://reader036.vdocuments.site/reader036/viewer/2022083006/56813b9d550346895da4d326/html5/thumbnails/6.jpg)
Today’s agenda
Finish Bellman-Ford algorithm
Look at a related problem: longest path problem