Implement connected component decomposition