Your browser sucks, JavaScript disabled! Gunnar's console needs JavaScript and WebAssembly. Git over SSH on port 2222 does not.

nordisk/facett

.nornir/population-graph-reasoning.md

Population Graph — the Sverige · Population showcase (design)

The Swedish 11-million-person population graph (the canonical knut-popsim model) rendered in facett-demo as three beautiful, linked, interactive graphs. Native AND the wasm web demo. THE showstopper graph tab.

Where it lives

The data source — knut-popsim (NOT re-invented)

knut-popsim (knut/crates/knut-popsim, lib knut_popsim) is the canonical, pure-Rust generator of the synthetic Swedish population graph: 12 labels (Person + 11 register entities), deterministic LCG, no falkordb / arrow / network / fs deps (optional serde only) → it compiles for wasm32-unknown-unknown. The demo depends on it by path (../../knut/crates/knut-popsim) and calls:

PopGraph is the "graph-mem database that works in wasm". pop_model builds a thin query/filter/LOD layer over it — it never invents a second model.

Honest about scale (the LAW)

You cannot draw 100M nodes (≈400M with entities — OOMs; wasm has a hard memory ceiling). So:

Scale field: a logarithmic slider 1M→100M + an 11M button. Default = the canonical 11,000,000.

The three linked views (one population, three lenses)

view what layout
Full the population as a force-clustered hub-and-spoke web people on a coarse per-kommun grid, entities orbiting each person; LOD-sampled to RENDER_CAP
Debt the enforcement sub-graph: Person → OWES → Debt → ESCALATES_TO → KfmCase three columns (Person | Debt | KfmCase), escalated rows first; KfmCase nodes ringed red
Kommun the per-kommun aggregation one node per kommun on its real lon/lat, sized by population (proportional-symbol map of Sweden), tied to nearest neighbours

A 3D view (graph3d tab) renders the same knut-popsim sample as a spun 3D force cloud (depth-shaded), via facett-graph3d.

Toggles (drive the render, observable in state_json)

Beauty (the whole point)

Each view renders through the shared facett_core::render L0 SDF kernel (the same kernel the maps + graphview draw through), lowered with a glow lane: a soft RingInstance halo behind every node marker, sized to the marker. Pure CPU SDF → it lights up identically native AND in wasm with no GPU dependency and no l1-vello feature. Nodes read as luminous orbs over a dark ground. Colours from the 12-label palette / kommun wheel / debt-heat scale. Kommun orbs are population-sized (engine NodeDecoration.scale).

Engine extensions (domain-agnostic, kept in the engine)

Observability (the LAW)

PopGraphTab::state_json() carries: n_persons, scale_min/max, generated_persons, gen_cap, render_cap, the analytic stats (total_nodes/edges + per_label), color_mode, active_labels, active_relations, and per-view {visible_nodes, total_nodes, edges, lit_px, zoom}. Plus a #[cfg(testmatrix)] functional_status emit from ui. Every view renders to a straight-RGBA Frame a test reads back (pop_graph_blob.rs) → PNG blobs at $TMPDIR/facett-demo/pop_*.png.

Tests (inject-assert, never no-crash)

wasm

cargo build -p facett-demo --target wasm32-unknown-unknown --no-default-features builds green — knut-popsim is wasm-clean and the L0+glow lane is CPU-only. The same GEN_CAP/RENDER_CAP caps apply in the browser. Deploys via cargo xtask deploy-pages (unchanged).

Future (→ korp)

This lives in facett-demo now; it will move to korp later (the surveillance / back- office tool). pop_model + pop_tab are self-contained over knut-popsim + facett-graphview, so the move is a copy of two modules + the dep.