diff options
author | pmlpm1986 <96069104+pmlpm1986@users.noreply.github.com> | 2022-09-01 09:34:43 +0200 |
---|---|---|
committer | Jarrod Millman <jarrod.millman@gmail.com> | 2022-09-30 09:49:45 -0700 |
commit | 0956e8407fb45c9b40e90d5178126355b1199d60 (patch) | |
tree | 1a5ddb47a2079ec29d0da351f4b4ce6f5ef31715 | |
parent | 5aeda33275b92e659f1880ee1662c8190740f5f0 (diff) | |
download | networkx-0956e8407fb45c9b40e90d5178126355b1199d60.tar.gz |
Improved documentation for all_simple_paths (#5944)
* Improved documentation for all_simple_paths
Improved the documentation for all_simple_paths.
* Update simple_paths.py
Black code style compliance edits.
-rw-r--r-- | networkx/algorithms/simple_paths.py | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/networkx/algorithms/simple_paths.py b/networkx/algorithms/simple_paths.py index 0ce27216..e19e4e4b 100644 --- a/networkx/algorithms/simple_paths.py +++ b/networkx/algorithms/simple_paths.py @@ -103,7 +103,9 @@ def all_simple_paths(G, source, target, cutoff=None): 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. + produces no output. If it is possible to traverse the same sequence of + nodes in multiple ways, namely through parallel edges, then it will be + returned multiple times (once for each viable edge combination). Examples -------- @@ -199,6 +201,13 @@ def all_simple_paths(G, source, target, cutoff=None): >>> all_paths [[0, 1, 3], [0, 1, 4], [2, 1, 3], [2, 1, 4]] + If parallel edges offer multiple ways to traverse a given sequence of + nodes, this sequence of nodes will be returned multiple times: + + >>> G = nx.MultiDiGraph([(0, 1), (0, 1), (1, 2)]) + >>> list(nx.all_simple_paths(G, 0, 2)) + [[0, 1, 2], [0, 1, 2]] + Notes ----- This algorithm uses a modified depth-first search to generate the |