Find the parent of a and b
a = Find ( parent , a ) NEW_LINE b = Find ( parent , b ) NEW_LINE if ( a == b ) : NEW_LINE INDENT return NEW_LINE DEDENT if ( rank [ a ] > rank [ b ] ) : NEW_LINE INDENT rank [ a ] += 1 NEW_LINE DEDENT if ( rank [ b ] > rank [ a ] ) : NEW_LINE INDENT swap ( a , b ) NEW_LINE DEDENT