if you want to arrange, use the queue. the queue maintains the insertion order. or you can use an implementation of a list of, say, two lists of arrays to interleave. But basically, the list also keeps order.
if you do not care about the order, you can use any installed implementations. sets do not preserve this order.
For example, in a BFS implementation, if you do not like the ordering of nodes, you can use two sets, old and new, to alternate, rather than in a queue.
source share