topogroup

1.0.1 • Public • Published

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

Dependencies (2)

Dev Dependencies (1)

Package Sidebar

Install

npm i topogroup

Weekly Downloads

2

Version

1.0.1

License

MIT

Last publish

Collaborators

  • tetsuo