gert-topo-sort
v1.0.0
Published
Topologically sort Gert graphs
Downloads
5
Maintainers
Readme
gert-topo-sort
Topologically sort Gert graphs
Usage
var Graph = require('gert').Graph;
var TopoSort = require('gert-topo-sort');
var graph = new Graph({
directed: true,
vertices: {
'Nap': [],
'Make Toast': ['Eat breakfast'],
'Pour juice': ['Eat breakfast'],
'Eat breakfast': ['Nap']
}
});
// ['Pour juice', 'Make Toast', 'Eat breakfast', 'Nap']
var morning = TopoSort(graph);
API
TopoSort(graph)
Returns an array of topologically sorted vertex ids from the directed, acyclic graph
. If graph
is undirected or cyclic, TopoSort()
will throw an error.