What is the algorithm for merging two different sets ?
inline int find(int x){ return (parent[x] == x ? x : find(parent[x])); }
inline bool merge(int x, int y){ x = find(x); y = find(y); if(x == y) return false; if(r[x] > r[y]) x = y + x — (y = x); parent[x] = y; if(r[x] == r[y]) r[y]++; return true; }
Thanks in advance.