All Pairs Shortest Path Examples While the illustrations which follow only show solutions from vertex A (or 1) for simplicity, students should note that as an All-Pairs problem the algorithm is computing similar information for each vertex.
Matrix Multiply Method for APSP
The graph for the Slow “Matrix Multiply” Method 2 3 4 1 3 8 2 -4 -5 1 7 4 5 6
π: 1 d: 3 Slow “Matrix Multiply” Method Initial conditions, e.g., L(1) 2 3 4 π: 1 d: 8 1 3 8 2 -4 -5 1 7 4 5 6 π: nil d: ∞ π: 1 d: -4
π: 1 d: 3 Slow “Matrix Multiply” Method L(2) – bolded values indicate change 2 3 4 π: 1 d: 8 1 3 8 2 -4 -5 1 7 4 5 6 π: 5 d: 2 π: 1 d: -4
π: 1 d: 3 Slow “Matrix Multiply” Method L(3) – bolded values indicate change 2 3 4 π: 4 d: -3 1 3 8 2 -4 -5 1 7 4 5 6 π: 5 d: 2 π: 1 d: -4
π: 3 d: 1 Slow “Matrix Multiply” Method L(4) – bolded values indicate change 2 3 4 π: 4 d: -3 1 3 8 2 -4 -5 1 7 4 5 6 π: 5 d: 2 π: 1 d: -4
The graph for the Fast “Matrix Multiply” Method 2 3 4 1 3 8 2 -4 -5 1 7 4 5 6
π: 1 d: 3 Fast “Matrix Multiply” Method Initial conditions, e.g., L(1) 2 3 4 π: 1 d: 8 1 3 8 2 -4 -5 1 7 4 5 6 π: nil d: ∞ π: 1 d: -4
π: 1 d: 3 Fast “Matrix Multiply” Method L(2) – bolded values indicate change 2 3 4 π: 1 d: 8 1 3 8 2 -4 -5 1 7 4 5 6 π: 5 d: 2 π: 1 d: -4
π: 3 d: 1 Fast “Matrix Multiply” Method L(4) – bolded values indicate change 2 3 4 π: 4 d: -3 1 3 8 2 -4 -5 1 7 4 5 6 π: 5 d: 2 π: 1 d: -4
Floyd-Warshall Method for APSP
The graph for the Floyd- Warshall Method 2 3 4 1 3 8 2 -4 -5 1 7 4 5 6
π: 1 d: 3 Floyd-Warshall Method Initial conditions, e.g., D(0) 2 3 4 π: 1 d: 8 1 3 8 2 -4 -5 1 7 4 5 6 π: nil d: ∞ π: 1 d: -4
π: 1 d: 3 Floyd-Warshall Method D(1) – No Changes 2 3 4 π: 1 d: 8 1 3 8 2 -4 -5 1 7 4 5 6 π: nil d: ∞ π: 1 d: -4
π: 1 d: 3 Floyd Warshall Method D(2) – bolded values indicate change 2 3 4 π: 1 d: 8 1 3 8 2 -4 -5 1 7 4 5 6 π: 2 d: 4 π: 1 d: -4
π: 1 d: 3 Floyd Warshall Method D(3) – No changes 2 3 4 π: 1 d: 8 1 3 8 2 -4 -5 1 7 4 5 6 π: 2 d: 4 π: 1 d: -4
π: 1 d: 3 Floyd Warshall Method D(4) – bolded values indicate change 2 3 4 π: 4 d: -1 1 3 8 2 -4 -5 1 7 4 5 6 π: 2 d: 4 π: 1 d: -4
π: 3 d: 1 Floyd Warshall Method D(5) – bolded values indicate change 2 3 4 π: 4 d: -3 1 3 8 2 -4 -5 1 7 4 5 6 π: 5 d: 2 π: 1 d: -4