Deque
Add or remove numbers at either end. The ring shows the front even when it crosses slot 0.
front is the index of the first element. The last one is at (front + size − 1) mod capacity.
In 0–1 BFS, after improving a distance, push the vertex to the front for a weight-0 edge or to the back for a weight-1 edge.
Removing from either end takes O(1). Growing a full deque takes O(n), giving O(1) amortized time per insertion.