1.6.1 • Published 4 years ago

digraph v1.6.1

Weekly downloads
5
License
MIT
Repository
github
Last release
4 years ago

NPM version Build Status Coverage Status

digraph

Digraph module provides several functions for working with directed graphs (digraphs) in JavaScript.

node.js

npm i digraph --save

browser

Use browserify.

API

var digraph = require('digraph');

digraph is a factory function creates directed graph object.

var g1 = digraph();

g.node() -> n

Digraph object has node factory function.

<Node> = g1.node(<N>)

Creates new node object if needed.

N: undefined

Constructs new noname node object.

N: {String}

Search for existing node object with this name. Constructs new node object with the name if can`t find existing node.

N: {Object}

Uses provided Object as node object descriptor. Search for existing node object if name: 'NodeName' is provided.

Examples:

var a = g1.node('a');

var node = g1.node; // can be detached

var b = node('b');
var c = node('c');

n.edge(n) -> e

Node object has edge factory that will search for the relevant edge or create one if needed.

Examples:

var a_b = a.edge(b);
var b_e = node('b').edge(node('e'));

var c_ = c.edge; // can be detached
var c_d = c_(d);
var c_e = c_(e);

g.edges

[<Edge>] = g1.edges.from(<Node>)

Return array of all outgoing edges.

[<Edge>] = g1.edges.to(<Node>)

Return array of all incoming edges.

[<Edge>] = g1.edges.at(<Node>)

g.get

[<Node>] = g.get.nodes

Return array of nodes in no particular order.

[<Edge>] = g.get.edges

Return array of edges in no particular order.

1.6.1

4 years ago

1.6.0

5 years ago

1.5.0

6 years ago

1.4.1

7 years ago

1.4.0

7 years ago

1.3.0

7 years ago

1.2.0

7 years ago

1.1.0

7 years ago

1.0.0

7 years ago

0.5.1

7 years ago

0.5.0

7 years ago

0.4.0

7 years ago

0.3.2

7 years ago

0.3.1

7 years ago

0.3.0

7 years ago

0.2.0

7 years ago

0.1.4

8 years ago

0.1.3

8 years ago

0.1.2

8 years ago

0.1.1

8 years ago

0.1.0

8 years ago

0.0.5

10 years ago

0.0.3

10 years ago

0.0.1

11 years ago

0.0.0

11 years ago