Update bfs-sequence.py

pull/1195/head
Rohan Janardhan 2023-07-04 22:14:02 +05:30 committed by GitHub
parent c36bc74fde
commit 262699fc7c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 3 deletions

View File

@ -1,7 +1,7 @@
""" """
BFS graph using Adjecency List BFS graph using Adjacency List
----------------------------------------------------------------------------------------- -----------------------------------------------------------------------------------------
-In Breadth First Search Sequence of any graph all children of a parent node -In Breadth-First Search Sequence of any graph all children of a parent node
is visited first and the children are stored in the QUEUE array and is visited first and the children are stored in the QUEUE array and
VISITED array. VISITED array.
-Children of nodes in QUEUE are visited one by one and stored in the QUEUE and -Children of nodes in QUEUE are visited one by one and stored in the QUEUE and
@ -33,7 +33,7 @@ def Display_BFS(curr:int ,Adj_Dict: dict[int, list[int]]) -> None: # displays BF
queue.append(i) queue.append(i)
visited.append(i) visited.append(i)
rear+=1 rear+=1
queue[front]=-1 # all nodes adjecent to curr are visited queue[front]=-1 # all nodes adjacent to curr are visited
front+=1 front+=1
if front==rear: # no new node to visit if front==rear: # no new node to visit
return return