source: frontend/node_modules/@rtsao/scc/README.md

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago

Fix frontend appearance

  • Property mode set to 100644
File size: 1.1 KB
Line 
1# `@rtsao/scc`
2
3Find strongly connected components of a directed graph using [Tarjan's algorithm](https://en.wikipedia.org/wiki/Tarjan%27s_strongly_connected_components_algorithm).
4
5This algorithm efficiently yields both a topological order and list of any cycles.
6
7## Installation
8
9```
10yarn add @rtsao/scc
11```
12
13```
14npm install @rtsao/scc
15```
16
17## Usage
18
19```js
20const scc = require("@rtsao/scc");
21
22const digraph = new Map([
23 ["a", new Set(["c", "d"])],
24 ["b", new Set(["a"])],
25 ["c", new Set(["b"])],
26 ["d", new Set(["e"])],
27 ["e", new Set()]
28]);
29
30const components = scc(digraph);
31// [ Set { 'e' }, Set { 'd' }, Set { 'b', 'c', 'a' } ]
32```
33
34#### Illustration of example input digraph
35```
36┌───┐ ┌───┐
37│ d │ ◀── │ a │ ◀┐
38└───┘ └───┘ │
39 │ │ │
40 ▼ ▼ │
41┌───┐ ┌───┐ │
42│ e │ │ c │ │
43└───┘ └───┘ │
44 │ │
45 ▼ │
46 ┌───┐ │
47 │ b │ ─┘
48 └───┘
49```
Note: See TracBrowser for help on using the repository browser.