@seregpie/bron-kerbosch
v1.0.1
Published
An implementation of the Bron-Kerbosch algorithm to find the maximal cliques in an undirected graph.
Downloads
46
Readme
BronKerbosch
BronKerbosch(edges)
An implementation of the Bron-Kerbosch algorithm to find the maximal cliques in an undirected graph.
| argument | description |
| ---: | :--- |
| edges
| An iterable of the edges to build the graph from. An edge is an array of two nodes. |
Returns the maximal cliques as an array of arrays.
setup
npm
npm i @seregpie/bron-kerbosch
Import inside an ES module.
import BronKerbosch from '@seregpie/bron-kerbosch';
or
Import inside a CommonJS module.
let BronKerbosch = require('@seregpie/bron-kerbosch');
browser
<script src="https://unpkg.com/@seregpie/bron-kerbosch"></script>
The module is globally available as BronKerbosch
.
usage
let edges = [[6, 4], [4, 3], [4, 5], [5, 2], [5, 1], [1, 2]];
let cliques = BronKerbosch(edges);
// => [[4, 6], [4, 3], [4, 5], [2, 5, 1]]