Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

graph-toposort

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

graph-toposort

> An implementation of [Kahn's Algorithm](https://en.wikipedia.org/wiki/Topological_sorting#Kahn.27s_algorithm) > for [topologically sorting](https://en.wikipedia.org/wiki/Topological_sorting) a > [graph.js](https://github.com/mhelvens/graph.js) instance.

  • 0.0.1
  • npm
  • Socket score

Version published
Weekly downloads
7
increased by133.33%
Maintainers
1
Weekly downloads
 
Created
Source

node-graph-toposort

An implementation of Kahn's Algorithm for topologically sorting a graph.js instance.

npm version build status

Install

$ npm install graph-toposort

Example

var toposort = require('graph-toposort');
var Graph = require('graph.js');

// a -> b -> c
var graph = new Graph(
  [ 'a', 'b' ],
  [ 'b', 'c' ]
);

var list = toposort(graph);
// [ 'a', 'b', 'c' ]

Usage

This algorithm is useful when determining what order to go in when dealing with a tree of dependencies. The graph must be acyclic, in other words it cannot have circular dependencies. (you must remove these yourself)

toposort(graph)

Given the input graph, it will return an Array of the vertex keys sorted topologically.

FAQs

Package last updated on 22 Oct 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc