Matrix Multiplication
Summarized notes from Introduction to Algorithms, Chapter 25
- dynamic programming algorithm for finding all-pairs shortest paths
- looks like repeated matrix multiplication
- compute shortest path by extending shortest path edge by edge
- Start with
which represents weights from original graph - after
repetitions will converge if no cycles -
Solution computes matrix
which will be the output -
Extend-shortest-paths method is used to update weight estimate:
1 2 3 4 5 6 7 8 9 |
|
Two versions
Slow All-Pairs
1 2 3 4 5 6 7 |
|
Faster All-Pairs
1 2 3 4 5 6 7 8 9 |
|
Complexity
Running Time | |
---|---|
Slow-APSP | |
Faster-APSP |
Why is Faster-APSP faster?
=> no need to compute all