Adding weighted quick-union with path compression