import queue


def bfs(G, start):
    """ A simple breadth-first search algorithm implemented using native queues. """
    seen = set()
    q = queue.Queue()
    # we don't care about threading so don't ask Queue to block execution
    q.put_nowait(start)

    while not q.empty():
        # get the waiting node, again without blocking execution
        u = q.get_nowait()

        if u not in seen:
            seen.add(u)
            # get all of u's neighbors and enqueue them
            for n in G[u]: q.put_nowait(n)

    return seen