tsort - node.js topological sort utility
npm install tsort
usage
var tsort = ; // create an empty graphvar graph = ; // add nodesgraph;graph;graph; // outputs: [ '0', 'a', 'b', 'c' ]consoledirgraph; // can add more than one nodegraph;// outputs: [ '0', '1', '2', '3', 'a', 'b', 'c' ]consoledirgraph; // can add in array formgraph;graph;// outputs: [ '0', '1', '2', '3', '1.5', 'a', 'b', 'c' ]consoledirgraph; // detects cyclesgraph;graph;// throws: Error: There is a cycle in the graph. It is not possible to derive a topological sort.graph;
license
MIT