Find all connected components in an undirected graph