Function to assign root
def Root ( idx ) : NEW_LINE INDENT i = idx ; NEW_LINE while ( i != id [ i ] ) : NEW_LINE INDENT id [ i ] = id [ id [ i ] ] NEW_LINE i = id [ i ] ; NEW_LINE DEDENT return i ; NEW_LINE DEDENT