This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
from cached_property import cached_property | |
import pytest | |
class Graph(object): | |
'''Solve the all-pairs shortest-path (APSP) problem using the Floyd-Warshall algorithm as described | |
in Section 25.2 of Cormen et al., Introduction to Algorithms (3rd ed.). The implementation is directly | |
from the pseudocode given there; in particular, there is no space optimization, and only the weights | |
of the shortest paths are computed; no predecessor pointers are stored to reconstruct the shortest paths.''' |