Returns the shortest path from source to target in a weighted graph G.
Parameters : | G : NetworkX graph source : node
target : node
weight: string, optional (default=’weight’) :
|
---|---|
Returns : | path : list
|
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(G,0,4))
[0, 1, 2, 3, 4]