add images to connected components and strongly connected components