My presentation all shortestpath
-
Upload
carlostheran -
Category
Technology
-
view
340 -
download
5
Transcript of My presentation all shortestpath
![Page 1: My presentation all shortestpath](https://reader035.fdocuments.in/reader035/viewer/2022062303/55892d45d8b42a2c388b45c9/html5/thumbnails/1.jpg)
All-Pairs Shortest PathTheory and Algorithms
Carlos Andres Theran SuarezProgram Mathematics and Scientific Computing
University of Puerto Rico [email protected]
October – 2011Mayaguez-Puerto Rico
Dr Marko Schütz
![Page 2: My presentation all shortestpath](https://reader035.fdocuments.in/reader035/viewer/2022062303/55892d45d8b42a2c388b45c9/html5/thumbnails/2.jpg)
Introduction
• In this section we consider de problem of finding shortest path between all pair of vertices in a directed graph .
– With a weight function where
For this goal we are going to use the adjacency-matrix of a graph.
• The input: is a which is adjacency-matrix of a • The output: is the matrix of SPL .
![Page 3: My presentation all shortestpath](https://reader035.fdocuments.in/reader035/viewer/2022062303/55892d45d8b42a2c388b45c9/html5/thumbnails/3.jpg)
Recall
• Single-Source shortest paths.• Nonnegative edge weight.– Dijkstra’s algorithm: Running time Array
Running time Binary heap Running time Fibonacci heap
• General.– Bellman-Ford: Running time
• UDG.– Breadth for search: Running time
![Page 4: My presentation all shortestpath](https://reader035.fdocuments.in/reader035/viewer/2022062303/55892d45d8b42a2c388b45c9/html5/thumbnails/4.jpg)
What do you think?
Can we solve all-pair shortest paths by running a single source-paths algorithms?
![Page 5: My presentation all shortestpath](https://reader035.fdocuments.in/reader035/viewer/2022062303/55892d45d8b42a2c388b45c9/html5/thumbnails/5.jpg)
What do you think?
Can we solve all-pair shortest paths by running a single source-paths algorithms? All-pair shortest paths.• Nonnegative edge weight
Dijkstra’s algorithm: Running time Array
![Page 6: My presentation all shortestpath](https://reader035.fdocuments.in/reader035/viewer/2022062303/55892d45d8b42a2c388b45c9/html5/thumbnails/6.jpg)
What do you think?
Can we solve all-pair shortest paths by running a single source-paths algorithms? All-pair shortest paths.• Nonnegative edge weight
Dijkstra’s algorithm: Running time Array Running time Binary heap
![Page 7: My presentation all shortestpath](https://reader035.fdocuments.in/reader035/viewer/2022062303/55892d45d8b42a2c388b45c9/html5/thumbnails/7.jpg)
What do you think?
Can we solve all-pair shortest paths by running a single source-paths algorithms? All-pair shortest paths.• Nonnegative edge weight
Dijkstra’s algorithm: Running time Array Running time Binary heap Running time Binary heap
![Page 8: My presentation all shortestpath](https://reader035.fdocuments.in/reader035/viewer/2022062303/55892d45d8b42a2c388b45c9/html5/thumbnails/8.jpg)
What do you think?
Can we solve all-pair shortest paths by running a single source-paths algorithms? All-pair shortest paths.• Nonnegative edge weight
Dijkstra’s algorithm: Running time Array Running time Binary heap Running time Binary heap
• General.Bellman-Ford: Running time
![Page 9: My presentation all shortestpath](https://reader035.fdocuments.in/reader035/viewer/2022062303/55892d45d8b42a2c388b45c9/html5/thumbnails/9.jpg)
What do you think?
Can we solve all-pair shortest paths by running a single source-paths algorithms? All-pair shortest paths.• Nonnegative edge weight
Dijkstra’s algorithm: Running time Array Running time Binary heap Running time Binary heap
• General.Bellman-Ford: Running time In a dense graph
![Page 10: My presentation all shortestpath](https://reader035.fdocuments.in/reader035/viewer/2022062303/55892d45d8b42a2c388b45c9/html5/thumbnails/10.jpg)
Predecessor Matrix
Let the predecessor Matrix, where
Now we define the predecessor subgraph of G for as .
Where
![Page 11: My presentation all shortestpath](https://reader035.fdocuments.in/reader035/viewer/2022062303/55892d45d8b42a2c388b45c9/html5/thumbnails/11.jpg)
Predecessor Matrix
![Page 12: My presentation all shortestpath](https://reader035.fdocuments.in/reader035/viewer/2022062303/55892d45d8b42a2c388b45c9/html5/thumbnails/12.jpg)
Outline
1. Present a dynamic programming algorithms based on matrix multiplication to solve the problem.
2. Dynamic programming algorithms called Floyd-Warshall algorithms.
3. Unlike the others algorithms, Johnson's algorithms used adjacency-list representation of a graph.
![Page 13: My presentation all shortestpath](https://reader035.fdocuments.in/reader035/viewer/2022062303/55892d45d8b42a2c388b45c9/html5/thumbnails/13.jpg)
Shortest path and matrix multiplication
1. The structure of shortest path.Let suppose that we have a shortest path form vertix to vertex , and suppose that have at most edge.
• If then have weight 0.
• If then where has at most edge, by lemma 24.1 is a shortest path from .
So
![Page 14: My presentation all shortestpath](https://reader035.fdocuments.in/reader035/viewer/2022062303/55892d45d8b42a2c388b45c9/html5/thumbnails/14.jpg)
2. A recursive solution. Let be the minimum weight of any path from vertex to vertex that contains at most edge.
Shortest path and matrix multiplication (cont.)
![Page 15: My presentation all shortestpath](https://reader035.fdocuments.in/reader035/viewer/2022062303/55892d45d8b42a2c388b45c9/html5/thumbnails/15.jpg)
3. Computing shortest-path weight bottom upInput . We compute
Shortest path and matrix multiplication (cont.)
![Page 16: My presentation all shortestpath](https://reader035.fdocuments.in/reader035/viewer/2022062303/55892d45d8b42a2c388b45c9/html5/thumbnails/16.jpg)
• Now we can see the relation to the matrix multiplication.
Let the matrix product of For We have .
If we set;
Shortest path and matrix multiplication (cont.)
![Page 17: My presentation all shortestpath](https://reader035.fdocuments.in/reader035/viewer/2022062303/55892d45d8b42a2c388b45c9/html5/thumbnails/17.jpg)
Computing the sequence of matrix
Shortest path and matrix multiplication (cont.)
![Page 18: My presentation all shortestpath](https://reader035.fdocuments.in/reader035/viewer/2022062303/55892d45d8b42a2c388b45c9/html5/thumbnails/18.jpg)
• Improving the running time.
Our goal, is to compute matrices, let go to see that we can compute with only matrix product.
Shortest path and matrix multiplication (cont.)
![Page 19: My presentation all shortestpath](https://reader035.fdocuments.in/reader035/viewer/2022062303/55892d45d8b42a2c388b45c9/html5/thumbnails/19.jpg)
Shortest path and matrix multiplication (cont.)
![Page 20: My presentation all shortestpath](https://reader035.fdocuments.in/reader035/viewer/2022062303/55892d45d8b42a2c388b45c9/html5/thumbnails/20.jpg)
Shortest path and matrix multiplication (cont.)
![Page 21: My presentation all shortestpath](https://reader035.fdocuments.in/reader035/viewer/2022062303/55892d45d8b42a2c388b45c9/html5/thumbnails/21.jpg)
The algorithm consider a intermediate vertices of a shortest path.1. The structure of a shortest path.Intermediate vertex in a any vertex of other than or, so it can be the set Let assume that the vertex of are and a subset for some .
• If of path , then all the vertices intermediate are in the set . Thus, a shortest path from vertex to vertex with all intermediate vertices in the set is also a shortest path form to with all in the set .
The Floyd-Warshall algorithm
![Page 22: My presentation all shortestpath](https://reader035.fdocuments.in/reader035/viewer/2022062303/55892d45d8b42a2c388b45c9/html5/thumbnails/22.jpg)
• If of path , we break down into is a shortest path from to, so of , thus is a shortest path form to with all in the set . Similarly is a shortest path form to with all in the set .
The Floyd-Warshall algorithm (cont)
![Page 23: My presentation all shortestpath](https://reader035.fdocuments.in/reader035/viewer/2022062303/55892d45d8b42a2c388b45c9/html5/thumbnails/23.jpg)
3. A recursive solution.
Since for every path, all intermediate vertices are in the set , matriz gives the final answer:
The Floyd-Warshall algorithm (cont)
![Page 24: My presentation all shortestpath](https://reader035.fdocuments.in/reader035/viewer/2022062303/55892d45d8b42a2c388b45c9/html5/thumbnails/24.jpg)
• input: A matrix • output: A matrix of shortest path weight.
• =
The Floyd-Warshall algorithm (cont)
![Page 25: My presentation all shortestpath](https://reader035.fdocuments.in/reader035/viewer/2022062303/55892d45d8b42a2c388b45c9/html5/thumbnails/25.jpg)
The Floyd-Warshall algorithm (cont)
![Page 26: My presentation all shortestpath](https://reader035.fdocuments.in/reader035/viewer/2022062303/55892d45d8b42a2c388b45c9/html5/thumbnails/26.jpg)
4. Constructing a Shortest pathWe compute the predecessor matrix just as the Floyd-warshall algorithm compute the matrices so.
Recursive formulation.
The Floyd-Warshall algorithm (cont)
![Page 27: My presentation all shortestpath](https://reader035.fdocuments.in/reader035/viewer/2022062303/55892d45d8b42a2c388b45c9/html5/thumbnails/27.jpg)
• It is asymtoticaly better than repeated squaring of matrices or the Floyd-Warshall algoritm.
• It use a subroutine both Dijkstra’s algorithm and Bellman-Ford algorithm.
• Johnson's algorithm use the technique of reweighting.
Johnson's algorithm for sparse graphs.
![Page 28: My presentation all shortestpath](https://reader035.fdocuments.in/reader035/viewer/2022062303/55892d45d8b42a2c388b45c9/html5/thumbnails/28.jpg)
Reweighting If has a negative weight edge but no negative weight cycle, we compute a new set of nonnegative edge weight that allow as to use Dijkstra’s algorithm.
The new set of edge must satisfy two condition.1. is a shortest path form is a shortest path
form .2. For all edges , the new weight is nonnegative.
Johnson's algorithm for sparse graphs (cont.).
![Page 29: My presentation all shortestpath](https://reader035.fdocuments.in/reader035/viewer/2022062303/55892d45d8b42a2c388b45c9/html5/thumbnails/29.jpg)
• Lemma Give a weighted, directed graph with weight funtion be any funtion mapping vertices to real numbers. For each edge , define.
Johnson's algorithm for sparse graphs (cont.).
![Page 30: My presentation all shortestpath](https://reader035.fdocuments.in/reader035/viewer/2022062303/55892d45d8b42a2c388b45c9/html5/thumbnails/30.jpg)
• Producing no negative weight by reweighting
Johnson's algorithm for sparse graphs (cont.).
![Page 31: My presentation all shortestpath](https://reader035.fdocuments.in/reader035/viewer/2022062303/55892d45d8b42a2c388b45c9/html5/thumbnails/31.jpg)
Johnson's algorithm for sparse graphs (cont.).
![Page 32: My presentation all shortestpath](https://reader035.fdocuments.in/reader035/viewer/2022062303/55892d45d8b42a2c388b45c9/html5/thumbnails/32.jpg)
Johnson's algorithm for sparse graphs (cont.).