Download presentation
Presentation is loading. Please wait.
Published byJulian Thomas Modified over 8 years ago
1
All-Pairs Shortest Paths & Essential Subgraph 01/25/2005 Jinil Han
2
Problem Description Finding shortest paths between all pairs of vertices in a directed graph G=(V,E) with nonnegative edge weights n=|V|, m=|E|
3
Well-known Algorithms Dijkstra’s algorithm running a single-source shortest paths algorithm |V| times O(n 2 lgn + nm), when implementing priority queue with a Fibonacci heap when all edge weights are nonnegative ** Fibonacci heap delete-min : O(lgn) priority change : O(1)
4
Well-known Algorithms Bellman-Ford algorithm d j (m+1) = min {d j (m), min {d k (m), +a kj }} O(n 2 m), O(n 4 ) if graph is dense negative edges are allowed Floyd-Warshall algorithm d ij (k) = min {d ij (k-1), d ik (k-1) + d kj (k-1) } O(n 3 ) negative edges are allowed Now, introduce two algorithms with running time of O(n 2 lgn+ns)
5
Run Dijkstra’s single source algorithm in parallel for all points in the graph Discover the hidden “shortest path structure” (essential subgraph H) Running time is equivalent to solving n single-source shortest path problems using only the edges in H O(n 2 lgn + ns), s = the number of edges in H s is likely to be small in practice, for general random graph, s = O(nlgn) almost surely expected running time is O(n 2 lgn) Algorithm Outline
6
Hidden Paths Algorithm Maintains a heap containing for each ordered pair of vertices u, v the best path from u to v found so far At each iteration, removes a path (u~v), from top of the heap (this is the optimal path from u to v) This path is now used to construct a set of new candidate paths If a new candidate path (w~t) is shorter, it replaces the current best path from w to t in the heap This maintains the optimality of the path at the top of the heap
7
Hidden Paths Algorithm
9
Example
10
Hidden Paths Algorithm Running time analysis 1. the initialization step : a heap of size O(n 2 ) 2. Step 1 & Step 2 : at most n(n-1) times at most n(n-1) delete-min operations 3. the only candidate paths created are those of the form (u,v~w) where both (u,v) and (v~w) are optimal The total number of candidate paths created is O(sn) At most one priority change operation associated with each candidate path
11
Hidden Path Algorithm Running time analysis
12
SHORT Algorithm Rather than iterating over nodes to solve n SSP problems, the algorithm iterates over edges and solves the SSP problem incrementally ( same as hidden Path algorithm) It is efficient because each distance need only be computed once The two algorithms would discover and report distances in different order The n shortest-path trees are constructed as a by-product of SHORT but not of Hidden Path algorithm
13
SHORT Algorithm Essential subgraph contain an edge (x,y) in E whenever d(x,y) =c(x,y) and there is no alternate path of equivalent cost, that is, edge (x,y) is in H when it is uniquely the shortest path in G between x and y G H
14
SHORT Algorithm Think of SHORT as an algorithm for constructing H SHORT builds H correctly (refer to a paper for proof)
15
SHORT Algorithm The Search Procedure returns a decision accept or reject depending on whether an alternate path exists in the partially built subgraph H i construct n single-source trees incrementally ** review of Dijkstra’s algorithm A shortest path tree T(v) rooted at v is built maintain a heap of fringe vertices which are not in T(v) but are adjacent to vertices in T(v) vertices are extracted from the fringe heap and added to T(v) Dijkstra-Process(v,x,y) operates on edge (x,y) when vertex x is added to T(v)
16
SHORT Algorithm The Search Procedure
17
SHORT Algorithm Example
18
SHORT Algorithm Running time analysis for each vertex, Dijkstra-Process processes each edge of H exactly once at most n inserts, deletes, and s decrease-key operations on the fringe heap O(s + nlgn) using Fibonacci heaps The total cost is therefore O(n 2 lgn + ns)
19
s in a Random graph To predict behavior of algorithms in practice for a large class of probability distributions on random graph, s= O(nlgn) consider dist. F on nonnegative edge weights, which doesn’t depend on n, such that F’(0) > 0 (Ex. Uniform and exponential) Th. Let G be complete directed graph, whose edge weights are chosen independently according to F. Then with probability 1-O(n -1 ), the diameter of G is O(lgn/n), and hence s = O(nlgn) with high probability the running time of the algorithms are O(n 2 lgn)
20
Essential Subgraph The essential subgraph is unique and that for every pair of vertices there is a shortest path between them comprising only edges in H H is the optimal subgraph for distance computations on G H is exactly the union of n SSP trees and H must contain a minimum spanning tree of G
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.