If both have same rank , then increase anyone 's rank
INDENT if rnk [ x ] == rnk [ y ] : NEW_LINE INDENT rnk [ x ] += 1 NEW_LINE DEDENT if rnk [ y ] > rnk [ x ] : NEW_LINE INDENT swap ( x , y ) NEW_LINE DEDENT parent [ y ] = x NEW_LINE DEDENT