* Fixed #4764

* Fixes #4764
This commit is contained in:
Jogendra Singh
2021-09-24 16:24:38 +05:30
committed by GitHub
parent 66a528b171
commit 5d02103b27

View File

@ -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