grape.general_graph.GeneralGraph.floyd_warshall_predecessor_and_distance

GeneralGraph.floyd_warshall_predecessor_and_distance()[source]

Serial Floyd Warshall’s APSP algorithm. The predecessors and distance matrices are evaluated, together with the nested dictionaries for shortest-path, length of the paths and efficiency attributes.

Note

Edges weight is taken into account in the distance matrix. Edge weight attributes must be numerical. Distances are calculated as sums of weighted edges traversed.

Returns

nested dictionary with key corresponding to source, while as value a dictionary keyed by target and valued by the source-target shortest path; nested dictionary with key corresponding to source, while as value a dictionary keyed by target and valued by the source-target shortest path length.

Return type

dict, dict