grape.general_graph.GeneralGraph.calculate_shortest_path

GeneralGraph.calculate_shortest_path()[source]

Choose the most appropriate way to compute the all-pairs shortest path depending on graph size and density. For a dense graph choose Floyd Warshall algorithm. For a sparse graph choose SSSP algorithm based on Dijkstra’s method.

Note

Edge weights of the graph are taken into account in the computation.

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