A queue processes items first in, first out (FIFO): remove the item at the front, then add new items at the back. In breadth-first search, this keeps route choices moving outward one level at a time. section 7.2
Delivery-route search
Breadth-first search queues route nodes from a depot, removes the next node to check it, and adds routes extended by one customer to the back. section 7.2
Listing 7.4 Initialize BFS.
import random
import itertools
NODES = ["Depot"] + [f"C{i}" for i in range(1, 10)] #A
distances = { (a, b):random.randint(5, 20)
➥for a in NODES for b in NODES if a != b } #B
root = RouteNode(route=["Depot"], cost=0) #C
queue = deque([root]) #D
best_route = None #D
best_cost = float('inf') #D
The initialization shows a Python deque holding the root route node. section 7.2





























