Compute the shortest path lengths from source to all reachable nodes.
Parameters: | G : NetworkX graph source : node
cutoff : integer, optional
|
---|---|
Returns: | lengths : dictionary
|
See also
Examples
>>> G=nx.path_graph(5)
>>> length=nx.single_source_shortest_path_length(G,0)
>>> length[4]
4
>>> print length
{0: 0, 1: 1, 2: 2, 3: 3, 4: 4}