Update bfs-sequence.py
parent
c36bc74fde
commit
262699fc7c
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue