the basic method, parallelized
the union find method parallelized