Connected components algorithm does not scale past 10,000 nodes
In algorithm implementation there are usually subtleties that are difficult to spot in a code review. In these cases, I always recommend to have a look at the implementation in other libraries in which smarter people have already spent time to get a good performance.

In this case, I think the library to look at is NetworkX and the implementation for the algorithm you're working on is here.

I hope this helps.