unite(x, y): // 2つの根を合併
    if rank[x] > rank[y]:
        parent[y] ← x
    else:
        parent[x] ← y
        if rank[x] = rank[y]:
            rank[y]++

# 合併のシミュレーション
unite(0, 1)
unite(2, 3)
unite(1, 3)
unite(4, 5)
unite(3, 5)