I wanted to have the reader try “running” the main loop of these graph search algorithms. Here’s an attempt. The frontier is blue; the current node is red; the neighboring nodes are green.

frontier = Queue() frontier.put(start) visited = {} visited[start] = True while not frontier.empty(): current = frontier.get() for next in graph.neighbors(current): if next not in visited: frontier.put(next) visited[next] = True

TO BE IMPLEMENTED: as you “run” the algorithm in the diagram, the frontier, current node, and neighbors should show up in the code. Maybe animate the transitions from frontier to current, and neighbor to frontier.

See also: this visualization from Chris Given