stores a graph of nodes and provides sorting and iteration


Stores a graph of nodes and provides topological sorting. Basically just an OO API for toposort so you can build your graph incrementally.

With packin or component

$ packin add jkroso/graph

then in your app:

var graph = require('graph')

Graph class

add node if not already in the graph

add two nodes with a relationship

add a relationship between two existing nodes

convert to a topologically sorted array

clone this Graph

new Graph(['c', 'a', 'd', 'b'])
  .addRelationship('a', 'b')
  .addRelationship('b', 'c')
  .addRelationship('c', 'd')
  .toArray() // => ['a', 'b', 'c', 'd'] 

Just run make and navigate your browser to the test directory.