Skip to content

Commit 4b5e249

Browse files
authored
Add doctest for BFS
1 parent 264cdfa commit 4b5e249

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

graphs/breadth_first_search_shortest_path.py

+4
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ def __init__(self, graph, source_vertex):
2424

2525
def breath_first_search(self):
2626
"""This function is a helper for running breath first search on this graph.
27+
>>> g = Graph(graph, "G")
28+
>>> g.breath_first_search()
29+
>>> g.parent
30+
{'G': None, 'C': 'G', 'A': 'C', 'F': 'C', 'B': 'A', 'E': 'A', 'D': 'B'}
2731
"""
2832
visited = {self.source_vertex}
2933
self.parent[self.source_vertex] = None

0 commit comments

Comments
 (0)