sets/weightquickunion

Keeps track of a set of elements partitioned into a number of disjoint (nonoverlapping) subsets. Allows to check whether the path between two nodes exists.
The algorithm is inspired by Robert Sedgewick's Java implementation. http://algs4.cs.princeton.edu/home/
Source:
Example
var QuickUnion = require('path-to-algorithms/' +
'src/sets/weightquickunion').QuickUnion;

var qunion = new QuickUnion(10);
qunion.union(0, 1);
qunion.union(2, 1);
qunion.union(3, 4);
qunion.union(8, 9);
qunion.union(4, 8);

console.log(qunion.connected(0, 9)); // false
console.log(qunion.connected(3, 9)); // true

Classes

QuickUnion