Package Exports
- @thi.ng/dgraph
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@thi.ng/dgraph) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
This project is part of the @thi.ng/umbrella monorepo.
About
Type-agnostic directed acyclic graph (DAG), using @thi.ng/associative maps & sets as backend.
Features
- cycle detection
- accessors for direct & transitive dependencies / dependents
- topological sorting
- iterable (in topo order)
Status
STABLE - used in production
Search or submit any issues for this package
Support packages
- @thi.ng/dgraph-dot - Customizable Graphviz DOT serialization for @thi.ng/dgraph
Installation
yarn add @thi.ng/dgraph
// ES module
<script type="module" src="https://unpkg.com/@thi.ng/dgraph?module" crossorigin></script>
// UMD
<script src="https://unpkg.com/@thi.ng/dgraph/lib/index.umd.js" crossorigin></script>
Package sizes (gzipped, pre-treeshake): ESM: 804 bytes / CJS: 865 bytes / UMD: 985 bytes
Dependencies
Usage examples
Several demos in this repo's /examples directory are using this package.
A selection:
| Screenshot | Description | Live| Source |
demo | |||
---|---|---|---|
![]() |
CLI util to visualize umbrella pkg stats | Source |
API
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]]
Authors
Karsten Schmidt
If this project contributes to an academic publication, please cite it as:
@misc{thing-dgraph,
title = "@thi.ng/dgraph",
author = "Karsten Schmidt",
note = "https://thi.ng/dgraph",
year = 2015
}
License
© 2015 - 2021 Karsten Schmidt // Apache Software License 2.0