Files
bzzz/install/config-ui/node_modules/@rtsao/scc/README.md
anthonyrawlins c177363a19 Save current BZZZ config-ui state before CHORUS branding update
🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-19 00:19:00 +10:00

50 lines
1.1 KiB
Markdown

# `@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 │ ─┘
└───┘
```