Spend more time when an edge is added (JOIN) to make it easier to figure out what's connected (CONNECTED).
Idea: Keep a linked list for each connected group of nodes and a pointer from each node to its list. Each time two groups are merged (a new edge is added), merge one list into the other, and change the pointers of the other to point to the one.
Q[v] is a pointer to a linked list of nodes in v's group.
Example.
Which group to relabel to make this fast?