Dynamic Connectivity
Last updated
Last updated
public class UF {
// initialize union-find data structure with N objects (0 to N β 1)
UF(int N);
// add connection between p and q
void union(int p, int q);
// are p and q in the same component?
boolean connected(int p, int q);
// component identifier for p (0 to N β 1)
int find(int p);
// number of components
int count();
}