adding connected components algo for undirected graph