Socket
Socket
Sign inDemoInstall

tsort

Package Overview
Dependencies
0
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

tsort

Topological sort on directed graphs.


Version published
Maintainers
1
Weekly downloads
118,898
decreased by-28.89%

Weekly downloads

Readme

Source

tsort - node.js topological sort utility

npm install tsort

usage

var tsort = require('tsort');

// create an empty graph
var graph = tsort();

// add nodes
graph.add('a', 'b');
graph.add('b', 'c');
graph.add('0', 'a');

// outputs: [ '0', 'a', 'b', 'c' ]
console.dir(graph.sort());

// can add more than one node
graph.add('1', '2', '3', 'a');
// outputs: [ '0', '1', '2', '3', 'a', 'b', 'c' ]
console.dir(graph.sort());

// can add in array form
graph.add(['1', '1.5']);
graph.add(['1.5', 'a']);
// outputs: [ '0', '1', '2', '3', '1.5', 'a', 'b', 'c' ]
console.dir(graph.sort());

// detects cycles
graph.add('first', 'second');
graph.add('second', 'third', 'first');
// throws: Error: There is a cycle in the graph. It is not possible to derive a topological sort.
graph.sort();

#license MIT

Keywords

FAQs

Last updated on 28 Feb 2013

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc