This preview shows pages 1–3. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: Shortest paths in graphs with negative edge weights • Let G = ( V,E ) be a directed graph with edge weights c uv for each edge ( u,v ) ∈ E . • Let | V | = n and | E | = m . • Cost c ( p ) of a path p = ( v ,v 1 ,...,v k ) is ∑ k i =1 c v i- 1 ,v i . • Shortest path from s to t is a path with minimum cost among all paths from s to t . • Problem: find a shortest path from s to all vertices. • Need the following fact: – FACT 1: If G has no negative cycles then there is a shortest path from s to t with at most n- 1 edges. 1 Bellman-Ford Algorithm • Works in the presence of negative weight edges but no negative cycles. • Let opt ( i,v ) be the minimum cost of a path from v to t using at most i edges. • To compute opt ( n- 1 ,s ). • Let P be an optimal path with cost opt ( i,v ). • There are two mutually exclusive cases: – CASE 1: P uses at most i- 1 edges: * opt ( i,v ) = opt ( i- 1 ,v )....
View Full Document
This note was uploaded on 02/18/2010 for the course CSB 1208204834 taught by Professor N/a during the Spring '10 term at École Normale Supérieure.
- Spring '10