Skip to content

Port Dagre 0.8.5 to Go - #1

Merged
alixander merged 2 commits into
mainfrom
agent/port-dagre-0.8.5
Aug 8, 2026
Merged

Port Dagre 0.8.5 to Go#1
alixander merged 2 commits into
mainfrom
agent/port-dagre-0.8.5

Conversation

@alixander

@alixander alixander commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Summary

  • port Dagre 0.8.5 and the required Graphlib 2.1.8 behavior to native Go
  • preserve ordered graph traversal, compound graphs, multiedges, self-loops, ranking, crossing minimization, and edge-label routing
  • port the upstream test corpus and add an optional JavaScript differential oracle
  • add CI for tests, race detection, and vet
  • preserve the upstream MIT notice and explicitly license Dagro contributions

Why

D2 currently embeds Dagre 0.8.5 as JavaScript and executes it through Goja. Dagro provides a behavior-compatible native Go implementation so D2 can remove that runtime and bundled asset without changing layout output.

Compatibility is intentionally measured against Dagre 0.8.5, the version embedded by D2. Later Dagre versions retain the same broad pipeline but contain behavior-changing ordering, positioning, compound-layout, API, and dependency changes.

Impact

This repository introduces the Go module github.com/d2lang/dagro. It has no third-party Go runtime dependencies. The public API includes the graph operations used by Dagre and D2 plus the layout entry point.

Dagro is MIT-licensed. Its LICENSE retains the Dagre/Graphlib copyright notice and also covers the new Dagro contributions; NOTICE records the exact upstream versions and commits used by the port.

Validation

  • DAGRO_DAGRE_JS=/absolute/path/to/dagre-0.8.5.js go test ./... -count=1
  • go test -race ./... -count=1
  • go vet ./...
  • the dependent D2 integration passes all 313 existing Dagre board and SVG goldens exactly

The dependent integration is d2lang/d2#2819.

@alixander
alixander marked this pull request as ready for review August 8, 2026 18:03
@alixander
alixander merged commit 141e7de into main Aug 8, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant