Function to make union
def Union ( x , y ) : NEW_LINE INDENT xpar = find ( x ) NEW_LINE ypar = find ( y ) NEW_LINE if ( Rank [ xpar ] < Rank [ ypar ] ) : NEW_LINE INDENT par [ xpar ] = ypar NEW_LINE DEDENT elif ( Rank [ xpar ] > Rank [ ypar ] ) : NEW_LINE INDENT par [ ypar ] = xpar NEW_LINE DEDENT else : NEW_LINE INDENT par [ ypar ] = xpar NEW_LINE Rank [ xpar ] += 1 NEW_LINE DEDENT DEDENT