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

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

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

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

View Full DocumentRight Arrow Icon
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
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.

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 Right Arrow Icon
Ask a homework question - tutors are online