Layer recurrence for breadth-first search
ProvedWilliamsonShmoys.bfs_layer_stepbfsgraph-theory
Let be a simple graph, vertices and . Suppose is not reachable from within distance , that is, not ( reachable from and ). Then
This is the recurrence behind layer-by-layer breadth-first search: the vertices at distance exactly are the vertices not yet reached that have a neighbour at distance . It is the correctness core of an RAM computation of Baker's BFS levels, which scans the adjacency row of each vertex once.
Formalization Note. is SimpleGraph.dist, which is for unreachable pairs; reachability is stated explicitly for that reason.
Preamble
import Mathlib set_option autoImplicit false
Formal statement
theorem WilliamsonShmoys.bfs_layer_step {V : Type} (G : SimpleGraph V) (r w : V) (t : ℕ)
(hw : ¬ (G.Reachable r w ∧ G.dist r w ≤ t)) :
(G.Reachable r w ∧ G.dist r w = t + 1) ↔
∃ u, G.Reachable r u ∧ G.dist r u = t ∧ G.Adj u w := by sorrySource
Standard BFS layering; used for the RAM computation of Baker levels in Williamson–Shmoys, Sect. 10.2, p. 270