NetworkX

Previous topic

networkx.shortest_path

Next topic

networkx.bidirectional_shortest_path

Quick search

networkx.shortest_path_length

shortest_path_length(G, source, target)

Return the shortest path length the source and target.

Raise an exception if no path exists.

G is treated as an unweighted graph. For weighted graphs see dijkstra_path_length.