110. CSR Adj<V, A> for pair/triple graphs and zero-copy array-to-list lowering (2026-11-21)
- Decision. Return a compressed sparse row struct
Adj<V, A>(start: List<0..=2_000_000_000>,arcs: List<A>, without/get/deg) fromGraph.directed/Graph.undirectedon plain pair/triple lists (directed_of_pairs,undirected_of_pairs,directed_of_triples,undirected_of_triples) instead of[V]List<...>, narrowGraph<V, E>.starttoList<0..=2_000_000_000>, preserve element narrowing throughBuiltin::CopyandBuiltin::ListFilled, lower 1D array arguments inlist_formviaList(edges)(Builtin::ArrayToList, zero-copy) rather than a[each cell for each cell in edges]copy loop, and pre-allocateorderwithunchecked:inner loops inRooted.build/Rooted.finish. - Why.
Graph.undirected(edges)onn = 10^6vertices previously allocatednseparatestd::vector<int>adjacency lists plus a 16 MB temporary edge-list copy, leavingbench/trees/root_benchat0.35–0.41 s / 121–124 MB(1.52xtime,1.77xmemory vs hand C++0.29 s / 69.8 MB). CSRAdj, zero-copyArrayToList, narrowingstart/atthroughCopy/ListFilled, and pre-allocatedRootedBFS bringroot_benchto0.22 s / 79.8 MB(0.76xtime,1.14xmemory vs hand C++). - Reverse. Change
directed_of_pairs/undirected_of_pairs/directed_of_triples/undirected_of_triplesinstdlib/graph.cpback to[V]List<...>and removeAdj<V, A>.