adding finding connected components in a graph