mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-02-17 06:48:09 +00: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