Near O(1) connected component grouping via Path Compression and Union by Rank
1 standard techniques
find + union for connectivity.