find connected components given marked cells of a 2D grid