Skip to content

Commit 31a4e29

Browse files
authored
Update BFS.py
1 parent 370e17a commit 31a4e29

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

Data Structures/Graphs/BFS.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
#Function To implement BFS (Breath First Search)
12
def Breathfirstsearch(matrix,start):
2-
visit=[start] #Keep Track of Visited elements
3+
visit=[start] #Keep Track of Visited Vertex
34
queue=[start] #BFS is implemented using queue
45
while(len(queue)) :
56
ele=queue.pop(0) #pop the element from queue ie first element from list
@@ -26,6 +27,6 @@ def valid(li,n):
2627
exit # Terminate the program for incorrect details
2728
matrix.append(li)
2829
start=int(input("Enter the starting vertix\n"))
29-
ans=Breathfirstsearch(matrix,start)
30+
ans=Breathfirstsearch(matrix,start)
3031
print("BFS order of the given graph is ",end=" ")
3132
print(*ans)

0 commit comments

Comments
 (0)