if parent[x] != x:
    parent[x] = Find(parent[x])
return parent[x]

def Union(x, y):
    """Merge sets containing elements x and y"""
x = Find(x)
y = Find(y)
if x == y:
    return
if rank[x] < rank[y]:
    parent[x] = y
elif rank[x] > rank[y]:
    parent[y] = x
else:
    parent[y] = x
rank[x] += 1
with open('disjointset.txt', 'r') as fd:
    for line in fd:
        fr, to = map(int, line.split())
Union(fr, to)
for n in range(N):
    pass
Finding components of very large graph