def BFS(G,s): for u in G.getVertices(): if u!=s: u.color='white' u.d=np.inf u.pre=None s.color='gray' s.d=0 s.pre=None Q=Queue() Q.Enqueue(s) while not Q.IsEmpty(): u=Q.Dequeue() for v in u.getConnections(): if v.color=='white': v.color='gray' v.d=u.d+1 v.pre=u Q.Enqueue(v) u.color='black'
from myqueue import Queue myq = Queue() myq.Enqueue('A') myq.Enqueue('B') myq.Enqueue('C') myq.Enqueue('D') myq.Enqueue('E') myq.PrintQueue() print("Elements in queue: ", myq.queueNo) # Please check queue.py for details myq.Dequeue() myq.PrintQueue() print("Elements in queue: ", myq.queueNo) # Please check queue.py for details myq.Enqueue('F') myq.PrintQueue() print("Elements in queue: ", myq.queueNo) # Please check queue.py for details