Skip to content

Commit 012e30f

Browse files
committed
Updated breadth first search
1 parent c8a992a commit 012e30f

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

pygorithm/searching/breadth_first_search.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,14 @@ def bfs(graph, startVertex):
1515
if vertex not in visited:
1616
visited.add(vertex)
1717
queue.extend(graph[vertex] - visited)
18-
18+
1919
return visited
2020

2121
# time complexities
2222
def time_complexities():
2323
return '''O(V + E) where V = Number of vertices and E = Number of Edges'''
24+
25+
# easily retrieve the source code of the bfs function
26+
def get_code():
27+
import inspect
28+
return inspect.getsource(bfs)

0 commit comments

Comments
 (0)