mirror of
https://hub.njuu.cf/TheAlgorithms/Python.git
synced 2023-10-11 13:06:12 +08:00
parent
66a528b171
commit
5d02103b27
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user