structure
Hex.GraphIso.Nauty.Sparse.Bfs
{n : Nat}
(G : SparseGraph n)
(root : Fin n)
(dist queue : Array Nat)
(head tail : Nat)
extends Hex.GraphIso.Nauty.Sparse.Queue n dist queue head tail :
BFS queue invariants together with attaining walks and the completed rows' edge inequalities.
Instances For
theorem
Hex.GraphIso.Nauty.Sparse.Bfs.initial
{n : Nat}
(G : SparseGraph n)
(root : Fin n)
:
Bfs G root ((Array.replicate n n).set! (↑root) 0) ((Array.replicate n 0).set! 0 ↑root) 0 1
theorem
Hex.GraphIso.Nauty.Sparse.Bfs.advance
{n : Nat}
{G : SparseGraph n}
{root : Fin n}
{dist queue : Array Nat}
{head tail : Nat}
(h : Bfs G root dist queue head tail)
(hh : head < tail)
(he : ∀ (v : Fin n), G.adj ⟨queue[head]!, ⋯⟩ v = true → dist[↑v]! < n ∧ dist[↑v]! ≤ dist[queue[head]!]! + 1)
:
theorem
Hex.GraphIso.Nauty.Sparse.Bfs.complete
{n : Nat}
{G : SparseGraph n}
{root : Fin n}
{dist queue : Array Nat}
{head tail : Nat}
(h : Bfs G root dist queue head tail)
(hdone : n ≤ tail ∨ tail ≤ head)
:
Distances G root dist
Both executable stopping conditions produce shortest paths. If the queue is full, its distance band covers the unprocessed rows as well.