Simple DAG (Directed Acyclic Graph) module with edge tagging.
Install
$ npm install dagjs
Usage
let Dag = ; let dag = ;// ...
Examples
Adding edges:
let dag = ;// add(from, to, tags, weight)dag;dag;dag;dag;// It results in a DAG:// follows admires// Mike ----3---> Josh --------> John// | ^// | |// | 50 follows and likes// | likes |// -----100---> Mary
Filtering by tag:
let likeDag = dag;// likeDag =// likes follows and likes// Mike --100--> Mary ---------50--------> Josh
Neighbouring:
let edgesToJosh = dag;// edgesToJosh =// [// {from:'Mike', to:'Josh', tags:['follows'], weight:3},// {from: 'Mary', to:'Josh', tags:['follows', 'likes'], weight: 50}// ] let edgesFromMary = dag;// edgesFromMary =// [// {from: 'Mary', to:'Josh', tags:['follows', 'likes'], weight: 50}// ] let neighbourhoodOfJosh = dag;// neighbourhoodOfJosh =// follows admires// Mike ----3---> Josh --------> John// ^// |// 50 follows and likes// |// Mary
Clones:
// shallow-clonelet shallowDag = dag; // deep-clonelet deepDag = dag;