Tiny graph data structure for Client or Server
var graph = require('tiny-graph'),
g = graph();
g.set_node_value('f', 3);
g.set_node_value('h', 21);
g.add('f', 'h');
g.set_edge_value('f', 'h', 100);
console.log(g.adjacent('f', 'h')); // true
console.log(g.neighbors('f')); // ['h']
console.log(g.get_edge_value('f', 'h')); // 100
tiny-graph can be installed from npm & bower, and supports AMD loaders or script tags.
Tests whether there is an edge from node x
to node y
Lists all nodes y
such that there is an edge from x
to y
Adds the edge from x
to y
, if it is not there
Removes the edge from x
to y
, if it is there
Returns the value associated with the node x
Sets the value associated with the node x
to v
Removes node x
from the graph, if it is there
Returns the value associated to the edge (x
, y
)
Sets the value associated to the edge (x
, y
) to v
Copyright (c) 2014 Jason Mulligan Licensed under the BSD-3 license