NetworkX

Previous topic

networkx.dijkstra_path_length

Next topic

networkx.single_source_dijkstra_path_length

networkx.single_source_dijkstra_path

single_source_dijkstra_path(G, source)

Return list of nodes in a shortest path between source and all other nodes reachable from source for a weighted graph.

Returns a dictionary of shortest path lengths keyed by target.

Parameters:

G : NetworkX graph

source : node label

starting node for path

Notes

Edge data must be numerical values for Graph and DiGraphs.

Examples

>>> G=nx.path_graph(5)
>>> path=nx.single_source_dijkstra_path(G,0)
>>> path[4]
[0, 1, 2, 3, 4]