# @rtsao/scc

> Find strongly connected components of a directed graph using [Tarjan's algorithm](https://en.wikipedia.org/wiki/Tarjan%27s_strongly_connected_components_algorithm).

Latest version **1.1.0** (published 2022-04-06) · MIT license · 0 weekly downloads

## Install

```sh
npm install @rtsao/scc
pnpm add @rtsao/scc
yarn add @rtsao/scc
bun add @rtsao/scc
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2022-04-06 |
| First published | 2019-04-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 3.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 9 |
| Maintainers | rtsao |

## Links

- npm: https://www.npmjs.com/package/@rtsao/scc
- Repository: https://github.com/rtsao/scc
- Homepage: https://github.com/rtsao/scc#readme
- Issues: https://github.com/rtsao/scc/issues
- npm.io page: https://npm.io/package/@rtsao/scc

## Recent versions

- 1.1.0 (latest) — 2022-04-06
- 1.0.0 — 2019-04-15

## README

# `@rtsao/scc`

Find strongly connected components of a directed graph using [Tarjan's algorithm](https://en.wikipedia.org/wiki/Tarjan%27s_strongly_connected_components_algorithm).

This algorithm efficiently yields both a topological order and list of any cycles.

## Installation

```
yarn add @rtsao/scc
```

```
npm install @rtsao/scc
```

## Usage

```js
const scc = require("@rtsao/scc");

const digraph = new Map([
  ["a", new Set(["c", "d"])],
  ["b", new Set(["a"])],
  ["c", new Set(["b"])],
  ["d", new Set(["e"])],
  ["e", new Set()]
]);

const components = scc(digraph);
// [ Set { 'e' }, Set { 'd' }, Set { 'b', 'c', 'a' } ]
```

#### Illustration of example input digraph
```
┌───┐     ┌───┐
│ d │ ◀── │ a │ ◀┐
└───┘     └───┘  │
  │         │    │
  ▼         ▼    │
┌───┐     ┌───┐  │
│ e │     │ c │  │
└───┘     └───┘  │
            │    │
            ▼    │
          ┌───┐  │
          │ b │ ─┘
          └───┘
```

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