Implementation of Weighted Quick Union-Find with Path Compression data structure.