Compute shortest path between source and all other nodes reachable from source.
Parameters: | G : NetworkX graph source : node label
cutoff : integer, optional
|
---|---|
Returns: | lengths : dictionary
|
See also
Notes
There may be more than one shortest path between the source and target nodes. This function returns only one of them.
Examples
>>> G=nx.path_graph(5)
>>> path=nx.single_source_shortest_path(G,0)
>>> path[4]
[0, 1, 2, 3, 4]