Remove consecutive duplicates in one pass.
Equations
Instances For
Equations
- Hex.SparseGraph.Builder.unique.go a [] = [a]
- Hex.SparseGraph.Builder.unique.go a (b :: xs) = if (a == b) = true then Hex.SparseGraph.Builder.unique.go a xs else a :: Hex.SparseGraph.Builder.unique.go b xs
Instances For
@[csimp]
Use the standard tail-recursive implementation in compiled code.
Sort a row and collapse repeated neighbours in linear time after sorting.
Equations
- Hex.SparseGraph.Builder.normalize xs = Hex.SparseGraph.Builder.unique (Hex.List.sort xs fun (a b : Fin n) => decide (a ≤ b))
Instances For
theorem
Hex.SparseGraph.Builder.sorted_normalize
{n : Nat}
(xs : List (Fin n))
:
List.Pairwise (fun (x1 x2 : Fin n) => x1 < x2) (normalize xs)
def
Hex.SparseGraph.Builder.checked
(n : Nat)
(edges : List (Nat × Nat))
(h : edges.all (Graph.validEdge n) = true)
:
Range-checking supplies erased proofs for the finite endpoints.
Equations
Instances For
Expose row normalization to the kernel while retaining the existing array map in compiled graph construction.
Equations
Instances For
@[simp]
@[inline]
Equations
Instances For
@[csimp]
Build from unordered Fin pairs, collapsing duplicates and dropping loops.
Scattering and packing are linear; each row is sorted separately.
Equations
Instances For
Checked edge-list builder: reject loops and out-of-range endpoints, otherwise normalize duplicate undirected pairs into compressed rows.
Equations
- Hex.SparseGraph.ofEdges? n edges = if h : edges.all (Hex.Graph.validEdge n) = true then some (Hex.SparseGraph.ofEdges (Hex.SparseGraph.Builder.checked n edges h)) else none
Instances For
Enumerate each undirected edge once, in increasing endpoint order.
Equations
Instances For
@[simp]