1.0.1 • Published 9 years ago

topogroup v1.0.1

Weekly downloads
1
License
MIT
Repository
-
Last release
9 years ago

topogroup

topologically sorts and divides a directed acylic graph into almost disjoint subsets of interconnected vertices.

example

var nodes = [ 'y', 'j', 'k', 'x' ];
var edges = [
  [ 'x', 'j' ],
  [ 'x', 'y' ],
  [ 'k', 'j' ],
  [ 'y', 'j' ],
];
var groups = topogroup(nodes, edges);
console.log(groups);

outputs:

[
 [ 'k', 'j' ],
 [ 'x', 'y', 'j' ],
 [ 'j' ]
]

api

var arr = topogroup(nodes, edges)

  • nodes is the array of vertices.
  • edges is the array of directed edges that describes the graph.

license

mit