node-graph-toposort
A modified implementation of Kahn's Algorithm for topologically sorting a graph.js instance.
Install
$ npm install graph-toposort
Example
var toposort = ;var Graph = ; // a -> b -> cvar graph = 'a' 'b' 'b' 'c' ; var list = ;// [ 'a', 'b', 'c' ]
Usage
This algorithm is useful when determining what order to go in when dealing with a tree of dependencies. While circular dependencies are being handled, it is still an experimental feature, so please report any problems you find with it.
toposort(graph)
Given the input graph
, it will return an Array
of the vertex keys sorted topologically.