Compute all shortest paths in the graph.
Parameters : | G : NetworkX graph source : node
target : node
weight : None or string, optional (default = None)
|
---|---|
Returns : | paths: generator of lists :
|
See also
shortest_path, single_source_shortest_path, all_pairs_shortest_path
Notes
There may be many shortest paths between the source and target.
Examples
>>> G=nx.Graph()
>>> G.add_path([0,1,2])
>>> G.add_path([0,10,2])
>>> print([p for p in nx.all_shortest_paths(G,source=0,target=2)])
[[0, 1, 2], [0, 10, 2]]