Added weighted union-find