networkx 2.8.2 Pypi GitHub Homepage
Other Docs
NotesParametersReturns
all_simple_edge_paths(G, source, target, cutoff=None)

A simple path is a path with no repeated nodes.

Notes

This algorithm uses a modified depth-first search to generate the paths . A single path can be found in $O(V+E)$ time but the number of simple paths in a graph can be very large, e.g. $O(n!)$ in the complete graph of order $n$.

Parameters

G : NetworkX graph
source : node

Starting node for path

target : nodes

Single node or iterable of nodes at which to end path

cutoff : integer, optional

Depth to stop the search. Only paths of length <= cutoff are returned.

Returns

path_generator: generator

A generator that produces lists of simple paths. If there are no paths between the source and target within the given cutoff the generator produces no output. For multigraphs, the list of edges have elements of the form :None:None:`(u,v,k)`. Where :None:None:`k` corresponds to the edge key.

Generate lists of edges for all simple paths in G from source to target.

See Also

all_shortest_paths
all_simple_paths
shortest_path

Examples

>>> g = nx.Graph([(1, 2), (2, 4), (1, 3), (3, 4)])
>>> for path in sorted(nx.all_simple_edge_paths(g, 1, 4)):
...     print(path)
[(1, 2), (2, 4)]
[(1, 3), (3, 4)]
>>> mg = nx.MultiGraph()
>>> mg.add_edge(1, 2, key="k0")
'k0'
>>> mg.add_edge(1, 2, key="k1")
'k1'
>>> mg.add_edge(2, 3, key="k0")
'k0'
>>> for path in sorted(nx.all_simple_edge_paths(mg, 1, 3)):
...     print(path)
[(1, 2, 'k0'), (2, 3, 'k0')]
[(1, 2, 'k1'), (2, 3, 'k0')]
See :

Local connectivity graph

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


GitHub : /networkx/algorithms/simple_paths.py#304
type: <class 'function'>
Commit: