{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

spneg - Shortest paths in graphs with negative edge weights...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
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 0 , 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
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
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 ). CASE 2: P uses i edges: * Let the first edge of P be ( v, w ). * opt ( i, v ) = c vw + opt ( i - 1 , w ).
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}