diff options
Diffstat (limited to 'networkx/classes/function.py')
-rw-r--r-- | networkx/classes/function.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/networkx/classes/function.py b/networkx/classes/function.py index fb24105f..a0807942 100644 --- a/networkx/classes/function.py +++ b/networkx/classes/function.py @@ -1279,7 +1279,10 @@ def number_of_selfloops(G): def is_path(G, path): - """Returns whether or not the specified path exists + """Returns whether or not the specified path exists. + + For it to return True, every node on the path must exist and + each consecutive pair must be connected via one or more edges. Parameters ---------- @@ -1296,6 +1299,8 @@ def is_path(G, path): """ for node, nbr in nx.utils.pairwise(path): + if node not in G: + return False if nbr not in G[node]: return False return True |