Find all-pairs shortest path lengths using Floyd’s algorithm.
Parameters : | G : NetworkX graph nodelist : list, optional
weight: string, optional (default= ‘weight’) :
|
---|---|
Returns : | distance : NumPy matrix
|
Notes
Floyd’s algorithm is appropriate for finding shortest paths in dense graphs or graphs with negative weights when Dijkstra’s algorithm fails. This algorithm can still fail if there are negative cycles. It has running time O(n^3) with running space is O(n^2).