Implementation of the Union-Find data structure for NodeJS.
$ npm install git+https://git@github.com/arnellebalane/union-find.gitThis package exposes four implementations of the Union-Find data structure.
import {
QuickFindUF,
QuickUnionUF,
WeightedQuickUnionUF,
PathCompressionUF
} from 'union-find';constructor(size): Initializes a new Union-Find data structure with a given size.union(source, target): Connects a node to another.connected(source, target)(Boolean): Checks whether two nodes are connected.
import { QuickFindUF } from 'union-find';
const uf = new QuickFindUF(10);
uf.union(4, 3);
uf.union(3, 8);
uf.connected(4, 8); // => true
uf.connected(1, 3); // => false# or `npm` if yarn is not available
$ yarn install
$ yarn testMIT License