@rtsao/scc

Find strongly connected components of a directed graph using Tarjan's algorithm.

Usage no npm install needed!

<script type="module">
  import rtsaoScc from 'https://cdn.skypack.dev/@rtsao/scc';
</script>

README

@rtsao/scc

Find strongly connected components of a directed graph using Tarjan's algorithm.

Installation

yarn add @rtsao/scc
npm install @rtsao/scc

Usage

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' } ]