Miss any of our Open RFC calls?Watch the recordings here! »

@thi.ng/dgraph

1.2.22 • Public • Published

dgraph

npm version npm downloads Twitter Follow

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

Support packages

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: 790 bytes / CJS: 850 bytes / UMD: 972 bytes

Dependencies

Usage examples

Several demos in this repo's /examples directory are using this package.

A selection:

Screenshot Description Live demo Source
CLI util to visualize umbrella pkg stats Demo Source

API

Generated API docs

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

License

© 2015 - 2020 Karsten Schmidt // Apache Software License 2.0

Install

npm i @thi.ng/dgraph

DownloadsWeekly Downloads

214

Version

1.2.22

License

Apache-2.0

Unpacked Size

44.6 kB

Total Files

10

Last publish

Collaborators

  • avatar