# lec16 - n CS 323 Lecture 16 o Design and Analysis of...

This preview shows pages 1–4. Sign up to view the full content.

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

View Full Document

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: n CS 323 Lecture 16 o Design and Analysis of Algorithms Hoeteck Wee Â· [email protected] http://www.cs.qc.edu/~hoeteck/f09/ Detecting a Negative Cycle BELLMAN-FORD I Input: weighted, directed graph G = ( V , E ) , start node s , destination t . I each edge e has a cost/weight/length ce and no negative cycles I Output: the shortest directed path from s to t or a negative cycle I Running time: O ( mn ) time SUBPROBLEM I opt [ i , v ] : cost of shortest v- t path using at most i hops I recursion: opt [ i , v ] = min { c ( v , w ) + opt [ i- 1 , w ] | ( v , w ) âˆˆ E } I no negative cycles â‡’ need at most n- 1 hops i.e. opt [ n , v ] = opt [ n- 1 , v ] for all nodes v I âˆƒ negative cycle â‡’ âˆƒ node v such that opt [ n , v ] < opt [ n- 1 , v ] then, shortest path from v to t with n hops contains a negative cycle Hoeteck Wee CS 323 Nov 9, 2009 2 / 5 Computing the minimum PROBLEM. compute the minimum of n numbers p ( ) , . . . , p ( n- 1 ) ....
View Full Document

## This note was uploaded on 05/31/2010 for the course COMPUTER S 700 taught by Professor Joewhite during the Spring '10 term at Universidad San MartÃ­n de Porres.

### Page1 / 11

lec16 - n CS 323 Lecture 16 o Design and Analysis of...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online