TopoLoom is a topology-first graph drawing kernel for JavaScript. It focuses on planarity, embeddings, decompositions, dual routing, and flow-based constraints — then hands those outputs to deterministic coordinate pipelines.
Tagline: Topology-first graph drawing kernel for JavaScript
- Kernel, not renderer: TopoLoom exposes explicit topology artifacts (rotation systems, half-edges, SPQR trees, dual graphs).
- Determinism: Stable iteration orders and reproducible outputs.
- Composable pipelines: Topology modules feed geometry modules without adapter glue.
import { graph, planarity, embedding, layout } from '@khalidsaidi/topoloom';
const g = graph.fromEdgeList([
['a', 'b'],
['b', 'c'],
['c', 'a'],
]);
const result = planarity.testPlanarity(g);
if (result.planar) {
const mesh = embedding.buildHalfEdgeMesh(g, result.embedding);
const drawing = layout.planarStraightLine(mesh);
console.log(drawing.positions);
}graph— mutable builder + immutable snapshot, adapters, JSON I/Odfs— SCC, bridges, biconnected components, BC-treeplanarity— deterministic planarity test + witness (K5/K3,3)embedding— rotation system → half-edge mesh + facesdual— dual graph + dual shortest pathsorder— st-numbering + bipolar orientationflow— min-cost flow solverdecomp— SPQR decomposition (S/P/R/Q) with skeletons + embedding controlslayout— planar straight-line, orthogonal, planarization pipeline
Live demo: https://topoloom.web.app
- Run locally:
pnpm -C apps/showcase dev - Build:
pnpm -C apps/showcase build - Regenerate curated gallery datasets:
pnpm datasets:build
The showcase is a Vite + React Router + Tailwind v4 + Radix SPA deployed to Firebase Hosting (apps/showcase/dist) with SPA rewrites enabled.
- Power Grid Network
- SNAP roadNet-CA
- Graph Drawing BU4P benchmarks
- Source + terms: https://graphdrawing.unipg.it/data.html
- SuiteSparse Hamm (add20, add32)
- Source: https://sparse.tamu.edu/Hamm
- Terms: https://sparse.tamu.edu/about
- OpenStreetMap downtown extract
- Source: https://www.openstreetmap.org
- License: https://opendatacommons.org/licenses/odbl/
- Attribution string used in UI:
© OpenStreetMap contributors, ODbL 1.0
Topology first, geometry second. Layout pipelines should not recompute planarity or embeddings if the kernel already provides them.
- Planarity testing uses a native core (WASM) and by default treats directed edges as undirected while ignoring self‑loops (loops are re‑injected into the embedding).
- Biconnected components and st‑numbering treat directed edges as undirected by default; self‑loops are ignored or reported as singleton blocks depending on the module.
- SPQR decomposition is defined on biconnected graphs;
spqrDecomposeSafe(largest block) andspqrDecomposeAll(forest) provide deterministic results for non‑biconnected inputs. - Dual routing automatically uses a maximal planar backbone on nonplanar inputs.
- Orthogonal layout planarizes non‑planar graphs before routing and assigns ports for high‑degree vertices to preserve orthogonal geometry.
- Use pnpm >= 9 and Node >= 20.
- Run:
pnpm -r typecheck,pnpm -r lint,pnpm -r test,pnpm -r build. - Keep outputs deterministic and serializable.
MIT