gert-topo-sort

1.0.0 • Public • Published

gert-topo-sort

Topologically sort Gert graphs

Build Status Coverage Status

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.

Dependencies (0)

    Dev Dependencies (4)

    Package Sidebar

    Install

    npm i gert-topo-sort

    Weekly Downloads

    4

    Version

    1.0.0

    License

    MIT

    Last publish

    Collaborators

    • devinivy