number of connected components in an undirected graph python