n
elements, where each element is its own group.[xi, yi]
, add yi
to the restricted set of xi
and vice versa.[uj, vj]
, perform the following steps:
a. Find the group representatives of uj
and vj
.
b. Check if merging the groups of uj
and vj
would violate any restrictions.
c. If no restrictions are violated, merge the groups and mark the request as successful.
d. If a restriction is violated, mark the request as unsuccessful.