Returns the shortest path lengths from source to all other reachable nodes in a weighted graph G.
Returns a dictionary of shortest path lengths keyed by target. Uses Dijkstra’s algorithm.
Parameters: | G : NetworkX graph source : node label
|
---|
See also
Notes
Edge data must be numerical values for XGraph and XDiGraphs.
Examples
>>> G=nx.path_graph(5)
>>> length=nx.single_source_dijkstra_path_length(G,0)
>>> length[4]
4
>>> print length
{0: 0, 1: 1, 2: 2, 3: 3, 4: 4}