all_shortest_paths(G, source, target, weight=None, method='dijkstra')
There may be many shortest paths between the source and target. If G contains zero-weight cycles, this function will not produce all shortest paths because doing so would produce infinitely many paths of unbounded length -- instead, we only produce the shortest simple paths.
Starting node for path.
Ending node for path.
If None, every edge has weight/distance/cost 1. If a string, use this edge attribute as the edge weight. Any edge attribute not present defaults to 1. If this is a function, the weight of an edge is the value returned by the function. The function must accept exactly three positional arguments: the two endpoints of an edge and the dictionary of edge attributes for that edge. The function must return a number.
The algorithm to use to compute the path lengths. Supported options: 'dijkstra', 'bellman-ford'. Other inputs produce a ValueError. If :None:None:`weight`
is None, unweighted graph methods are used, and this suggestion is ignored.
If :None:None:`method`
is not among the supported options.
If :None:None:`target`
cannot be reached from :None:None:`source`
.
A generator of all paths between source and target.
Compute all shortest simple paths in the graph.
>>> G = nx.Graph()See :
... nx.add_path(G, [0, 1, 2])
... nx.add_path(G, [0, 10, 2])
... print([p for p in nx.all_shortest_paths(G, source=0, target=2)]) [[0, 1, 2], [0, 10, 2]]
The following pages refer to to this document either explicitly or contain code examples using this.
networkx.algorithms.simple_paths.all_simple_edge_paths
networkx.algorithms.shortest_paths.generic.all_shortest_paths
networkx.algorithms.simple_paths.all_simple_paths
networkx.algorithms.simple_paths.shortest_simple_paths
networkx.algorithms.shortest_paths.generic._build_paths_from_predecessors
Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.
Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)
SVG is more flexible but power hungry; and does not scale well to 50 + nodes.
All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them