Dagre

Automatic layout engine for directed graphs in JavaScript

Library
npm
v3.1.1
5,804 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
72 /100 Good
Development Activity 56
Maintenance 56
Community 76
Maturity 60
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
84 /100 Excellent
Architecture 88
Code Quality 85
Innovation 78
Learning Curve 60

Dagre is a JavaScript library that computes the positions of nodes and edges for directed graphs, so you can render clean, readable diagrams on the client without hand-placing anything. You describe a graph as nodes and edges with sizes and labels, call a single layout function, and Dagre assigns x/y coordinates and edge routing points using a layered (Sugiyama-style) algorithm.

It is rendering-agnostic: Dagre only does the math, leaving you free to draw the result with SVG, Canvas, D3, React, or any other toolkit. This separation is why it underpins many higher-level diagramming tools and flowchart renderers across the ecosystem.

What You Get

  • A single layout(graph) call that assigns x/y coordinates to nodes and routing points to edges
  • Configurable layout direction (top-bottom, left-right), node/edge spacing, and ranking alignment
  • A bundled graphlib Graph data structure for building and querying the input graph
  • Support for compound (nested/cluster) graphs and edge labels that reserve their own space
  • Rendering independence, so results can be drawn with SVG, Canvas, D3, or any framework

Common Use Cases

  • Auto-laying out flowcharts, state machines, and process diagrams
  • Visualizing dependency trees, build graphs, or data pipelines
  • Powering interactive node-and-edge editors and diagramming apps
  • Rendering DAGs such as workflow, org, or provenance graphs

Under The Hood

Architecture - Dagre’s layout() entry point (lib/layout.ts) builds an internal working graph and runs an ordered pipeline of transformation passes over it: makeSpaceForEdgeLabels, acyclic.run (breaks cycles), nestingGraph.run (for compound graphs), rank (assigns nodes to layers via lib/rank/network-simplex.ts), order (crossing minimization using barycenter and median heuristics under lib/order/), position (x-coordinate assignment via the Brandes-Köpf algorithm in lib/position/bk.ts), then edge normalization and denormalization, finally writing coordinates back onto the input graph. Each stage is a small focused module, making the classic Sugiyama layered-drawing method easy to follow end to end.

Tech Stack - Written in TypeScript and compiled with esbuild via build.ts into CJS, ESM, and type-declaration bundles. Its only runtime dependency is @dagrejs/graphlib (the sibling graph data-structure library), keeping the footprint small. Tooling includes Jest for tests, ESLint with typescript-eslint, and tsx for build/version scripts.

Code Quality - The repository carries an extensive test suite (~41 spec files under test/, mirroring the lib/ module layout, including targeted tests for ranking, ordering, and positioning) plus a benchmark harness. Modules are small and single-purpose, types are declared centrally in lib/types.ts, and the layered algorithm’s stages are individually covered, reflecting a mature, well-tested codebase.

API Design - The public surface is deliberately minimal: import dagre, build a Graph, set node/edge/graph labels, and call dagre.layout(g) to have coordinates written in place. This one-call ergonomics is a strength, though most configuration options and examples live in the project wiki rather than the terse in-repo README, which raises the initial discovery curve for newcomers.

Used by 47 apps in this directory

TypeScript
72%
AGPL 3.0

APITable

Databases · Low Code Platforms

15,623

API-first collaborative spreadsheet-database platform that auto-generates REST APIs and lets teams build internal tools, CRMs, and dashboards without code.

View details
71
Repo Health
77
Technical
60
Dependency
Built with
TypeScript 72%
Java 22%
Updated 3 weeks ago
Go
85%
Apache 2.0

Argo Workflows

Data Engineering · Devops

17,006

The most popular Kubernetes-native workflow engine for orchestrating containerized DAGs, ML pipelines, CI/CD, and parallel batch jobs at scale.

View details
96
Repo Health
90
Technical
68
Dependency
Built with
Go 85%
TypeScript 11%
Updated 4 days ago
Rust
86%
Other

Arroyo

Analytics · Data Engineering

5,039

A distributed stream processing engine written in Rust that lets you write SQL to run stateful, real-time computations over data streams with subsecond results.

View details
86
Repo Health
74
Technical
62
Dependency
Built with
Rust 86%
Updated 1 weeks ago
Python
62%
MIT

AutoGen

AI Development · Automation

61,194

Build autonomous and human-in-the-loop multi-agent AI systems with a layered, event-driven Python and .NET framework pioneered at Microsoft Research.

View details
56
Repo Health
78
Technical
73
Dependency
Built with
Python 62%
C# 25%
TypeScript 12%
Updated 5 months ago
TypeScript
70%
Other

Budibase

Low Code Platforms · No Code Platforms

28,324

Build AI agents, automations, and internal apps on a single open-source platform with full self-hosting control.

View details
91
Repo Health
81
Technical
63
Dependency
Built with
TypeScript 70%
Svelte 26%
Updated 1 weeks ago
Java
72%
Other

ByteChef

AI Agents · Automation

1,003

Unified open-source platform for AI agent orchestration and workflow automation with 180+ connectors, MCP support, and durable execution.

View details
85
Repo Health
82
Technical
67
Dependency
Built with
Java 72%
TypeScript 28%
Updated 5 days ago
TypeScript
99%
AGPL 3.0

Cherry Studio

AI Assistants

52,202

All-in-one AI desktop client with 300+ assistants and multi-model support

View details
89
Repo Health
84
Technical
70
Dependency
Built with
TypeScript 99%
Updated 4 days ago
Ruby
61%
GPL 2.0

Discourse

Community

47,915

Open-source community platform with dynamic trust levels, real-time chat, and a powerful plugin architecture for self-hosted forums.

View details
89
Repo Health
89
Technical
67
Dependency
Built with
Ruby 61%
JavaScript 32%
Updated 4 days ago
TypeScript
92%
MIT

Dittofeed

Automation · Marketing

2,968

Open-source omni-channel customer engagement platform for automating transactional and marketing messages via email, SMS, WhatsApp, Slack, and mobile push.

View details
54
Repo Health
75
Technical
62
Dependency
Built with
TypeScript 92%
Updated 6 months ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers