summaryrefslogtreecommitdiff
path: root/graph.py
diff options
context:
space:
mode:
authorSylvain Th?nault <sylvain.thenault@logilab.fr>2009-11-23 14:45:11 +0100
committerSylvain Th?nault <sylvain.thenault@logilab.fr>2009-11-23 14:45:11 +0100
commit57b10e1b76dd3bd3c834bacd338076de6e35cabe (patch)
tree3f59f0a76e5bcb0bd760b37edac7b2fe906a2473 /graph.py
parentb7e84e3fc5418641041f95a80f08fe053c004c27 (diff)
parent1b4d12cbd2ab6e6e586743df592648faa42fa26e (diff)
downloadlogilab-common-57b10e1b76dd3bd3c834bacd338076de6e35cabe.tar.gz
Diffstat (limited to 'graph.py')
-rw-r--r--graph.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/graph.py b/graph.py
index 573a1ba..ddd5abd 100644
--- a/graph.py
+++ b/graph.py
@@ -189,16 +189,16 @@ def has_path(graph_dict, fromnode, tonode, path=None):
node has key associated to a list of nodes directly reachable from it.
Return None if no path exists to go from `fromnode` to `tonode`, else the
- first path found
+ first path found (as a list including the destination node at last)
"""
if path is None:
path = []
elif fromnode in path:
- return False
+ return None
path.append(fromnode)
for destnode in graph_dict[fromnode]:
if destnode == tonode or has_path(graph_dict, destnode, tonode, path):
- return path[1:]
+ return path[1:] + [tonode]
path.pop()
return None