We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 370e17a commit 31a4e29Copy full SHA for 31a4e29
Data Structures/Graphs/BFS.py
@@ -1,5 +1,6 @@
1
+#Function To implement BFS (Breath First Search)
2
def Breathfirstsearch(matrix,start):
- visit=[start] #Keep Track of Visited elements
3
+ visit=[start] #Keep Track of Visited Vertex
4
queue=[start] #BFS is implemented using queue
5
while(len(queue)) :
6
ele=queue.pop(0) #pop the element from queue ie first element from list
@@ -26,6 +27,6 @@ def valid(li,n):
26
27
exit # Terminate the program for incorrect details
28
matrix.append(li)
29
start=int(input("Enter the starting vertix\n"))
- ans=Breathfirstsearch(matrix,start)
30
+ ans=Breathfirstsearch(matrix,start)
31
print("BFS order of the given graph is ",end=" ")
32
print(*ans)
0 commit comments