added connected components method, but it doesn't yet work