Connected Components Problem In Matrix