':type n: int
:type edges: List[List[int]]
:rtype: int'

def countComponents(self, n, edges):

    union_find = UnionFind(n)
    for (i, j) in edges:
        union_find.union_set(i, j)
    return union_find.count
