nuvai-layouts

Graph layout for Rust

Same graph.
Eight drawings.

nuvai-layouts works out where every node and edge of a graph should go: layered, organic, tree, radial, orthogonal or circular. Every algorithm returns the same Layout, so one renderer draws them all.

A 24-node tree laid out by Tidy tree
Fig. 1 — the same 24-node tree, laid out by Tidy tree. Computed by the library when this page was built.

The layouts

Pick the drawing that fits the graph.

Each figure is the library's own output, computed when this page was built, on a graph that suits the algorithm. The pen colour shows the family.

  • Layered direction and flow
  • Organic distance and clusters
  • Trees hierarchy
  • Other rings and areas
Sugiyama layout of 16 nodes

Sugiyama

Fig. 2 · Gansner et al. 1993; Brandes & Köpf 2001

A build pipeline with one feedback edge. The cycle is broken, layers are ranked by network simplex, crossings minimised, edges drawn as splines.

16 nodes · 24 edges · 3 crossings · 3 edges reversed

Orthogonal (TSM) layout of 8 nodes

Orthogonal (TSM)

Fig. 3 · Tamassia 1987

The cube graph on a grid: planar embedding, right-angle bends, node boxes. A deterministic baseline, not a bend-optimal one.

8 nodes · 12 edges · fixed-embedding tier

ForceAtlas2 layout of 30 nodes

ForceAtlas2

Fig. 4 · Jacomy et al. 2014

Two communities joined by two bridges. Degree-weighted repulsion, approximated with Barnes-Hut, pulls each community together.

30 nodes · 88 edges · 1000 iterations

Stress (SGD) layout of 81 nodes

Stress (SGD)

Fig. 5 · Zheng, Pawliczek & Meyerhenke 2019

A 9 × 9 grid. Distances on the page track distances in the graph, so the grid comes out square.

81 nodes · 144 edges

Stress majorization layout of 20 nodes

Stress majorization

Fig. 6 · Gansner, Koren & North 2005

The Petersen-family graph GP(10, 3), solved by SMACOF with monotone energy.

20 nodes · 30 edges

Kamada-Kawai layout of 20 nodes

Kamada-Kawai

Fig. 7 · Kamada & Kawai 1989

The dodecahedron GP(10, 2), one Newton step per node at a time.

20 nodes · 30 edges

Spectral layout of 72 nodes

Spectral

Fig. 8 · Hall 1970; Koren 2003

A 12 × 6 grid placed by the Laplacian's two lowest non-trivial eigenvectors.

72 nodes · 126 edges · 30 iterations

Tidy tree layout of 31 nodes

Tidy tree

Fig. 9 · Buchheim, Jünger & Leipert 2002

A 31-node tree in linear time; subtrees never overlap and identical subtrees draw identically.

31 nodes · 30 edges

Radial tree layout of 46 nodes

Radial tree

Fig. 10 · Eades 1992

A deeper tree on rings, each subtree's angle proportional to its leaf count.

46 nodes · 45 edges

Circular layout of 18 nodes

Circular

Fig. 11 · Six & Tollis 1999

A sparse random graph on one ring, with nodes placed in breadth-first order.

18 nodes · 26 edges

Treemap layout of 17 nodes

Treemap

Fig. 12 · Bruls, Huijsen & van Wijk 2000

Weighted nodes as squarified rectangles; area is proportional to weight.

17 nodes

How it fits

Many algorithms in, one Layout out.

Algorithms never draw and renderers never lay out. Everything meets in one data type, so adding an algorithm gives every renderer something new to draw, and adding a renderer draws every algorithm.

Inputs (DOT, Mermaid, petgraph, your own graph or tasks) feed the GraphRef and TaskRef traits, which feed the algorithms; every algorithm produces a Layout, which feeds SVG, PNG, HTML canvas, egui, terminal and file exports. DOTMermaidpetgraphYour graphYour tasksGraphRefTaskRefSugiyamaForce & SFDPStress & KKTreesOrthogonalGantt · CPM · PERTLayoutSVGPNGHTML canvaseguiTerminalDOT · Mermaid · JSON
Fig. 13 — this diagram is itself a graph, laid out by the library's Sugiyama with 0 crossings.

Bring your graph

Implement GraphRef on your own type, use the petgraph adapter, or import DOT and Mermaid text. Project plans come in through TaskRef.

Get one Layout

Positions, sizes and shapes, edge routes as polylines or Bézier curves, labels and styles, an optional time axis, and depth for 2.5D views. It serialises to JSON and back.

Draw it anywhere

SVG and PNG files, an interactive HTML canvas, an egui widget, or a terminal through ratatui. Or export DOT, Mermaid and JSON for other tools.

Scheduling

Project plans are graphs too.

Give it tasks, durations and links, and the critical-path method schedules them before the Gantt layout draws them. Links can be finish-to-start, start-to-start, finish-to-finish or start-to-finish, each with a lag or a lead.

Add optimistic, likely and pessimistic estimates and you also get a PERT mean, a standard deviation and the chance of finishing by a date. When two critical paths tie, the result says that those figures are optimistic.

  • Critical path: 7 of 9 tasks
  • Has slack
  • Progress
Gantt chart of a 9-task release plan lasting 14 time units, with 7 tasks on the critical path 01234567891011121314DesignPrototypeDesign reviewCore engineRenderersIntegrationDocsTestingRelease
Fig. 14 — scheduled by CPM and laid out by the Gantt layout. Total duration 14 time units.

Quality

Measured, with the misses printed.

Against Graphviz dot

The target for the layered layout is at least 90% layer agreement and at most 20% crossing delta per graph against Graphviz dot, on 12,811 graphs (11,534 from Rome-Lib, 1,277 North DAGs). The gate needs 80% of graphs to pass. The shipped default does not meet it.

3,433 of 12,811 graphs pass with the default. The best opt-in configuration (balanced network-simplex ranking plus sifting-plateau ordering at 256 restarts) reaches 9,828, at about 125× the default ordering work. Measured on dot 2.42.4.

2,266 tests pass

Unit, property and quality tests across the workspace: no NaN coordinates, bounding-box containment, determinism, and per-algorithm correctness. 13 tests are ignored.

cargo test --workspace --features petgraph,serde --no-fail-fast, counted 2026-10-06.

Same seed, same drawing

Every random choice is seeded from the config, so a layout is reproducible run to run on the same runtime. Native and WebAssembly builds are not promised to match bit for bit.

Clean-room, with sources named

Algorithms are implemented from the published papers. GPL and LGPL code is never read; permissively licensed references are named. Each module states its papers, the references it consulted and the ones it did not.

Orthogonal drawings, stated plainly

The orthogonal layout is a deterministic baseline. Where it realises a planar embedding it draws with zero crossings, and on small inputs an independent checker confirms the bends are minimal. It does not claim minimum bends, crossings or area in general.

Want to use it?

nuvai-layouts is proprietary to Nuvai and not published as a crate. Write to us to evaluate it on your own graphs.

Request access

or email team@nuvai.dev