nx_wiki_graph.nx
buildroot/runtime/wiki/nx_wiki_graph.nx
about
nx_wiki_graph.nx -- wiki R4: static connections / link-graph view.
COMPOSES: nx_wiki_index_builder (page corpus: count + per-rowid title/url/
body) and nx_wiki_backlinks (the shared forward-[[wikilink]] extractor +
slug matcher -- so graph edges and the backlinks panel agree on what a link
is). nx_syscalls for scratch.
MODEL:
node = a page in the doc store (one per rowid).
edge = a forward [[wikilink]] from page A's body to another page B that
EXISTS as a node. src -> dst.
broken = a forward [[wikilink]] whose target resolves to NO node (link
rot). Broken links are COUNTED but are NOT nodes and NOT edges --
a dangling reference is rot, not a connection.
OUTPUT: a self-contained, deterministic <svg> with a CIRCULAR layout -- nodes
evenly spaced on a circle (positions from a fixed integer unit-circle table,
no floating point, no trig dependency), <line> for each edge, <circle> +
<text> for each node label. NO <script>, NO event handlers -> static SVG is
sovereign and renders identically everywhere. (An interactive/force-directed
graph is a documented JS follow-on, deliberately out of scope.)
Hygiene: M1 out-params; M3 capped loops; M5 bounded indexing; M6 real
semantics; M7 named constants; M8 propagated verdicts.
Status: V1 (wiki R4). 2026-06-15. license_tier: ORIGINAL
dependencies 3 imports · 2 importers
imports: nx_syscalls.nxnx_wiki_index_builder.nxnx_wiki_backlinks.nx
imported by: _wiki_backlinks_gate.nxnx_wiki_routes.nx
structs
| 55 | struct NxWikiGraph |
consts
| 32 | const NX_WGRAPH_OK: i64 = 0 |
| 33 | const NX_WGRAPH_BAD_INPUT: i64 = 2680 |
| 34 | const NX_WGRAPH_OVERFLOW: i64 = 2681 |
| 35 | const NX_WGRAPH_LOOP_BUDGET: i64 = 2682 |
| 38 | const NX_WGRAPH_MAX_NODES: i64 = 1000 // mirrors doc-store docs cap |
| 39 | const NX_WGRAPH_MAX_EDGES: i64 = 8192 // total edges across corpus cap |
| 40 | const NX_WGRAPH_MAX_LINKS_PP: i64 = 512 // forward links per page cap |
| 41 | const NX_WGRAPH_LOOP_BUDGET_C: i64 = 8000000 |
| 42 | const NX_WGRAPH_LABEL_GUARD: i64 = 512 // per-label byte cap (M3/M5) |
| 46 | const NX_WGRAPH_W: i64 = 800 |
| 47 | const NX_WGRAPH_H: i64 = 800 |
| 48 | const NX_WGRAPH_CX: i64 = 400 |
| 49 | const NX_WGRAPH_CY: i64 = 400 |
| 50 | const NX_WGRAPH_R: i64 = 320 // ring radius |
| 51 | const NX_WGRAPH_NODE_R: i64 = 7 // node dot radius |
| 52 | const NX_WGRAPH_TBL: i64 = 24 // unit-circle table entries |
functions
| 70 | func nx_wgraph_unit(k: i64, out_sin: *i64) -> i64 called by 1: nx_wgraph_node_xy |
| 107 | func nx_wgraph_node_xy(i: i64, nc: i64, out_x: *i64, out_y: *i64) -> i64 |
| 128 | func nx_wiki_graph_build(store: *NxWikiDocStore, g: *NxWikiGraph) -> i64 |
| 208 | func nx_wiki_graph_node_count(g: *NxWikiGraph) -> i64 called by 1: main |
| 212 | func nx_wiki_graph_edge_count(g: *NxWikiGraph) -> i64 called by 1: main |
| 216 | func nx_wiki_graph_broken_count(g: *NxWikiGraph) -> i64 called by 1: main |
| 227 | func nx_wgraph_emit(out: *u8, off: i64, cap: i64, s: *u8) -> i64 called by 1: nx_wiki_graph_render_svg |
| 236 | func nx_wgraph_emit_bytes(out: *u8, off: i64, cap: i64, src: *u8, n: i64) -> i64 called by 1: nx_wiki_graph_render_svg |
| 247 | func nx_wgraph_emit_num(out: *u8, off: i64, cap: i64, v: i64) -> i64 |
| 270 | func nx_wiki_graph_render_svg(store: *NxWikiGraph, doc_store: *NxWikiDocStore, |