This project is part of the @thi.ng/umbrella monorepo.
Type-agnostic directed acyclic graph (DAG), using @thi.ng/associative maps & sets as backend.
- cycle detection
- accessors for direct & transitive dependencies / dependents
- topological sorting
- iterable (in topo order)
STABLE - used in production
yarn add @thi.ng/dgraph
Package sizes (gzipped): ESM: 0.7KB / CJS: 0.8KB / UMD: 0.9KB
Several demos in this repo's /examples directory are using this package.
A selection:
CLI util to visualize umbrella pkg stats
import { DGraph } from "@thi.ng/dgraph";
g = new DGraph();
// dependencies from a -> b
g.addDependency([1, 2], [10, 20]);
g.addDependency([3, 4], [30, 40]);
g.addDependency([1, 2], [3, 4]);
// add isolated nodes
g.addNode([100, 200]);
g.sort();
// [[30, 40], [3, 4], [10, 20], [100, 200], [1, 2]]
Karsten Schmidt
© 2015 - 2020 Karsten Schmidt // Apache Software License 2.0