networkx.single_source_shortest_path_length
networkx.all_pairs_shortest_path_length
Return dictionary of shortest paths between all nodes.
The dictionary only has keys for reachable node pairs.
cutoff is optional integer depth to stop the search - only paths of length <= cutoff are returned.
See also floyd_warshall.