# lec19 - Introduction to Algorithms 6.046J/18.401J LECTURE...

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

November 21, 2005 Copyright © 2001-5 by Erik D. Demaine and Charles E. Leiserson L1 9 .1 Introduction to Algorithms 6.046J/18.401J L ECTURE 1 9 Shortest Paths III All-pairs shortest paths Matrix-multiplication algorithm Floyd-Warshall algorithm Johnson’s algorithm Prof. Charles E. Leiserson

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

View Full Document
November 21, 2005 Copyright © 2001-5 by Erik D. Demaine and Charles E. Leiserson L1 9 .2 Shortest paths Single-source shortest paths Nonnegative edge weights ± Dijkstra’s algorithm: O ( E + V lg V ) General ± Bellman-Ford algorithm: O ( VE ) DAG ± One pass of Bellman-Ford: O ( V + E )
November 21, 2005 Copyright © 2001-5 by Erik D. Demaine and Charles E. Leiserson L1 9 .3 Shortest paths Single-source shortest paths Nonnegative edge weights ± Dijkstra’s algorithm: O ( E + V lg V ) General ± Bellman-Ford: O ( VE ) DAG ± One pass of Bellman-Ford: O ( V + E ) All-pairs shortest paths Nonnegative edge weights ± Dijkstra’s algorithm | V | times: O ( VE + V 2 lg V ) General ± Three algorithms today.

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

View Full Document
November 21, 2005 Copyright © 2001-5 by Erik D. Demaine and Charles E. Leiserson L1 9 .4 All-pairs shortest paths Input: Digraph G = ( V , E ) , where V = {1, 2, …, n } , with edge-weight function w : E R . Output: n × n matrix of shortest-path lengths δ ( i , j ) for all i , j V .
November 21, 2005 Copyright © 2001-5 by Erik D. Demaine and Charles E. Leiserson L1 9 .5 All-pairs shortest paths Input: Digraph G = ( V , E ) , where V = {1, 2, …, n } , with edge-weight function w : E R . Output: n × n matrix of shortest-path lengths δ ( i , j ) for all i , j V . I DEA : Run Bellman-Ford once from each vertex. Time = O( V 2 E ) . Dense graph ( n 2 edges) ⇒Θ ( n 4 ) time in the worst case. Good first try!

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

View Full Document
November 21, 2005 Copyright © 2001-5 by Erik D. Demaine and Charles E. Leiserson L1 9 .6 Dynamic programming Consider the n × n adjacency matrix A = ( a ij ) of the digraph, and define d ij ( m ) = weight of a shortest path from i to j that uses at most m edges.
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 10/19/2010 for the course CS 477 taught by Professor Gewali during the Spring '08 term at University of Nevada, Las Vegas.

### Page1 / 23

lec19 - Introduction to Algorithms 6.046J/18.401J LECTURE...

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

View Full Document
Ask a homework question - tutors are online