The allocated BFS queue contains every discovered vertex exactly once. Its distance order and frontier band justify both append operations and the early exit when all vertices have been discovered.
Instances For
theorem
Hex.GraphIso.Nauty.Sparse.Queue.initial
{n : Nat}
(root : Fin n)
:
Queue n ((Array.replicate n n).set! (↑root) 0) ((Array.replicate n 0).set! 0 ↑root) 0 1
theorem
Hex.GraphIso.Nauty.Sparse.Queue.add
{n : Nat}
{dist queue : Array Nat}
{head tail v : Nat}
(h : Queue n dist queue head tail)
(hh : head < tail)
(hv : v < n)
(hd : dist[v]! = n)
(hn : dist[queue[head]!]! + 1 < n)
:
Discovering an unseen neighbour appends it once and gives it the next distance after the current head. The head stays fixed during its row scan.