Skip to content

Architecture

graphraum consumes positioned nodes and edges. It does not fetch data or infer graph semantics. Its optional force helpers produce positions independently from the renderer.

flowchart LR
  App[Application graph state] -->|nodes, edges, positions| Graphraum[graphraum]
  Layout[Layout worker or server] -->|positions| App
  Graphraum --> Viewport[Spatial viewport query]
  Viewport --> Scene[Three.js scene]
  Scene --> Nodes[One InstancedMesh]
  Scene --> Edges[One LineSegments geometry]
  Graphraum -->|picked node ID| App

This keeps layout work independently replaceable and prevents a complete force simulation from blocking the first useful render.

Layout producers can send GraphraumLayoutPositions batches: node IDs plus transferable XYZ Float32Array data. The host calls applyLayout() for each batch, so useful positions can appear before full convergence. The package also exports dimension-aware static, clustered, and incremental force helpers; applications still decide where and when they run.

graphraum renders when data, selection, camera controls, mode, or container size changes. It does not keep an idle animation loop alive. The one exception is an opt-in 3D auto-orbit (setAutoOrbit), which runs a frame loop only while it is actively orbiting and only renders on those frames, without rebuilding node or edge instances. Calls within one browser frame are coalesced through requestAnimationFrame.

Opt-in interactionQuality is a small governor on top of on-demand rendering. Camera changes mark motion, each rendered frame after a camera change is timed, and three slow frames in a row lower one tier. A tier is a pixel ratio and a budget scale; it reuses the same maxVisibleEdges, maxVisibleNodes and setPixelRatio paths as full quality and rematerializes the viewport once per tier change. One idle timer restores tier 0, so the tier cannot oscillate. It adds no draw call and never touches data.

In 2D, graphraum queries visible nodes from its spatial grid with an overscan margin, derives unique incident edges without scanning the full edge list, and compacts that subset into the existing node and edge GPU buffers. The renderer remains at two draw calls; the opt-in node glow adds one bounded halo draw call only while a visible node glows. Opt-in 3D depth of field adds four post-process draw calls only on frames that blur.

When visible nodes exceed maxVisibleNodes, graphraum bins them into representative spatial density clusters. Density mode enters above 110% of the budget and exits below 85% so small camera changes do not flicker between tiers. Nodes always draw over edges, in 2D and 3D. In 3D nodes still hide each other by depth, but an edge never covers a node, even where it passes in front of one: a node behind an edge shows on top of it. Edges also no longer depth-sort among themselves in 3D: where they overlap, they draw in batch order. This keeps node faces readable at busy hubs at the cost of these depth cues.

When incident edges exceed maxVisibleEdges, graphraum applies a deterministic overview budget and reports that decision through diagnostics. The budget keeps edges of selected, focused and hovered nodes and selected edges first, then the edges whose endpoints have the most connections. Equal scores are told apart by a fixed hash of the edge index, so an edge’s rank does not depend on the other candidates and panning only changes the edges at the cut. In 2D, edges that cover less than 0.75 CSS pixels on screen are dropped before the budget is applied (subPixelEdgesSkipped); the focus lens and 3D skip this cut. Application-specific clustering and semantic aggregation remain host concerns.

The host remains responsible for:

  • layout and progressive position updates;
  • labels, clustering, and domain-specific semantic level of detail;
  • keyboard navigation and an accessible node list;
  • domain actions such as expand, focus, archive, or inspect;
  • persistence and synchronization.

graphraum provides the rendering primitive, not a replacement application architecture. Visual fidelity is progressive: GPU batches for overview and exploration, host HTML for a hard-capped focus set. See ADR: Fidelity on demand.

Graphology is the canonical mutable graph input (PRO-248). Its core graph object supplies node/edge identity, typed attributes, events, traversal, and serialization. bindGraphology() subscribes to that contract and renders visual attributes; graphraum does not require Graphology’s optional layout or algorithm packages.

The existing array snapshot remains useful for static data, transport boundaries, fixtures, and one-shot rendering.