Skip to content

Latest commit

 

History

History

dgraph

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

@thi.ng/dgraph

npm version npm downloads Mastodon 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

Search or submit any issues for this package

Support packages

Related packages

  • @thi.ng/adjacency - Sparse & bitwise adjacency matrices, lists and selected traversal algorithms for directed & undirected graphs
  • @thi.ng/dot - Graphviz document abstraction & serialization to DOT format
  • @thi.ng/system - Minimal and explicit dependency-injection & lifecycle container for stateful app components

Installation

yarn add @thi.ng/dgraph

ES module import:

<script type="module" src="https://cdn.skypack.dev/@thi.ng/dgraph"></script>

Skypack documentation

For Node.js REPL:

const dgraph = await import("@thi.ng/dgraph");

Package sizes (brotli'd, pre-treeshake): ESM: 776 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 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

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 - 2023 Karsten Schmidt // Apache License 2.0