Added connected component algorithm