Download presentation
Presentation is loading. Please wait.
1
All-Pairs Shortest Paths HONG-MING CHU 2013/10/31
2
Refernece Lecture slides from Prof. Hsin-Mu Tsai’s course slides and Prof. Ya- Yuin Su course slides.
3
Today’s Goal Quick recap of single source shortest path Floyd-Warshall algorithm Johson algorithm
4
Things we have learned so far Single-source shortest paths problem Two algorithms Bellman Ford algorithm Dijakstra’s algorithm Several properties about shorthest path
5
Optimal Substructure V0V0 ViVi VjVj VkVk
6
Triangle inequality
7
Algortihms we have learned Graph typeAlgorithmRunnging Time Unweighted graphBFSO(V+E) Non-negative edge weight graph DijkstraO(E+VlgV) General graphBellman-FordO(VE) DAGBellman-FordO(V+E)
8
Algortihms we have learned
9
Algorithms we have learned Graph typeAlgorithmRunnging Time Unweighted graph BFSO(V+E)O(V) Non-negative edge weight graph DijsktraO(E+VlgV)O(VlgV) General graphBellman-FordO(VE) DAGBellman-FordO(V+E)O(V)
10
All-pair shortest paths
11
But how…….? Recall that shortest paths has some useful properties. One of them is that a shortest path has an optimal substructure. As soon as we realize this……. Dynamic programming may be a good choice to solve this problem!
12
Floyd-Warshall algorithm
13
The transition function
14
The transition function(Cont.)
15
Pseudo code
16
An Alternative: Transitive closure of a directed graph
17
An Alternative: Transitive closure of a directed graph(Cont.)
18
Another idea
19
Johnson’s algorithm
20
Theorem
21
Theorem(Cont.) The same for every path
22
Collorary
23
Difference constraints
24
Difference constraints(Cont.)
25
V1V1 V2V2 V3V3 2 3 -2 S 0 0 0
26
Difference constraints(End)
27
Return to Johnson Algorthim
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.