1.0.0 • Published 8 years ago

gert-topo-sort v1.0.0

Weekly downloads
7
License
MIT
Repository
github
Last release
8 years ago

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.