Skip to content

Commit 0829e8c

Browse files
Santosh BandichodeSantosh Bandichode
authored andcommitted
Used correct function names in recursive calls and fixed the doctest
1 parent 86e56e0 commit 0829e8c

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

patterns/other/graph_search.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def find_path_dfs(self, start, end, path=None):
1717
return path
1818
for node in self.graph.get(start, []):
1919
if node not in path:
20-
newpath = self.find_path(node, end, path[:])
20+
newpath = self.find_path_dfs(node, end, path[:])
2121
if newpath:
2222
return newpath
2323

@@ -29,7 +29,7 @@ def find_all_paths_dfs(self, start, end, path=None):
2929
paths = []
3030
for node in self.graph.get(start, []):
3131
if node not in path:
32-
newpaths = self.find_all_path(node, end, path[:])
32+
newpaths = self.find_all_paths_dfs(node, end, path[:])
3333
paths.extend(newpaths)
3434
return paths
3535

@@ -42,7 +42,7 @@ def find_shortest_path_dfs(self, start, end, path=None):
4242
shortest = None
4343
for node in self.graph.get(start, []):
4444
if node not in path:
45-
newpath = self.find_shortest_path(node, end, path[:])
45+
newpath = self.find_shortest_path_dfs(node, end, path[:])
4646
if newpath:
4747
if not shortest or len(newpath) < len(shortest):
4848
shortest = newpath
@@ -87,7 +87,7 @@ def main():
8787
>>> print(graph1.find_shortest_path_dfs('A', 'D'))
8888
['A', 'B', 'D']
8989
>>> print(graph1.find_shortest_path_bfs('A', 'D'))
90-
['A', 'B', 'C']
90+
['A', 'B', 'D']
9191
"""
9292

9393

0 commit comments

Comments
 (0)