mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-07-05 01:09:40 +08:00
@ -26,7 +26,10 @@ def union_set(x, y):
|
||||
disjoint set tree will be more flat.
|
||||
"""
|
||||
x, y = find_set(x), find_set(y)
|
||||
if x.rank > y.rank:
|
||||
if x == y:
|
||||
return
|
||||
|
||||
elif x.rank > y.rank:
|
||||
y.parent = x
|
||||
else:
|
||||
x.parent = y
|
||||
|
Reference in New Issue
Block a user