Skip to content
Topologically sort Gert graphs
JavaScript
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
lib
test
.gitignore
.travis.yml
LICENSE
README.md
package.json

README.md

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.

You can’t perform that action at this time.