Returns the shortest path length from source to target in a weighted graph.
Parameters : | G : NetworkX graph source : node label
target : node label
weight: string, optional (default=’weight’) :
|
---|---|
Returns : | length : number
|
Raises : | NetworkXNoPath :
|
See also
Notes
Edge weight attributes must be numerical. Distances are calculated as sums of weighted edges traversed.
Examples
>>> G=nx.path_graph(5)
>>> print(nx.dijkstra_path_length(G,0,4))
4