# tsort

> Topological sort on directed graphs.

Latest version **0.0.1** (published 2013-02-28) · MIT license · 0 weekly downloads

## Install

```sh
npm install tsort
pnpm add tsort
yarn add tsort
bun add tsort
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.1 |
| Published | 2013-02-28 |
| First published | 2013-02-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 13 |
| Author | Ekin Koc |
| Maintainers | eknkc |
| Keywords | dependency, graph, topological, sort, graph |

## Links

- npm: https://www.npmjs.com/package/tsort
- Repository: git@github.com:eknkc/tsort
- npm.io page: https://npm.io/package/tsort

## Alternatives

- [apollo-link-http-common](https://npm.io/package/apollo-link-http-common.md) — 879.0K weekly downloads
- [react-relay](https://npm.io/package/react-relay.md) — 336.8K weekly downloads
- [relay-test-utils](https://npm.io/package/relay-test-utils.md) — 181.6K weekly downloads
- [@vendure/core](https://npm.io/package/@vendure/core.md) — 14.8K weekly downloads
- [@pnpm/deps.graph-sequencer](https://npm.io/package/@pnpm/deps.graph-sequencer.md) — 13.4K weekly downloads

## Recent versions

- 0.0.1 (latest) — 2013-02-28

## README

# tsort - node.js topological sort utility

    npm install tsort

## usage

```js
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

---
_Source: https://npm.io/package/tsort · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
