# allpairs - All Pairs Shortest Paths Let G =(V E be a...

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

All Pairs Shortest Paths Let G = ( V,E ) be a directed graph with edge weights c uv for each edge ( u,v ) E . Let V = { 1 , 2 , ··· ,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: ﬁnd a shortest path from vertex i to vertex j for all vertices 1 i,j n . Need the following fact: – FACT 1: If G has no negative cycles then there is a shortest path from i to j with at most n - 1 edges. Non-negative edge weights: Dijkstra’s algorithm with each vertex as source. Time is O ( nm log n ) with binary heap data structure. Negative edge weights: Bellman-Ford algorithm with each vertex as source. Time is O ( n 2 m ). 1

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

View Full Document
All Pairs Shortest Paths : Characterization For any pair of vertices i,j V , let P k ij be a shortest path from i to j such that all intermediate vertices (excludes i and j ) along this path are from the set
This is the end of the preview. Sign up to access the rest of the 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.

### Page1 / 6

allpairs - All Pairs Shortest Paths Let G =(V E be a...

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

View Full Document
Ask a homework question - tutors are online