def _find_clusters(mst_graph, vertices):
    """Find the cluster class for each vertex of the MST graph.
    It uses the DFS-like algorithm to find clusters.
    
    Args:
        mst_graph (dict): A non-empty graph representing the MST.
        vertices (list): A list of unique vertices.
    
    Returns:
        A list containing the group id of each vertex.
    """
    cluster_id = 0
    classes = [-1] * len(vertices)
    unexplored = vertices.copy()        
    
    while unexplored:
        start = unexplored.pop()
        classes[start] = cluster_id
        explored, stack = set(), [start]

        while stack:
            v = stack.pop()

            if v in explored:
                continue

            if v != start:
                unexplored.remove(v)

            explored.add(v)
            classes[v] = cluster_id

            if v not in mst_graph:
                continue

            for adj in mst_graph[v]:
                if adj in explored: continue
                stack.append(adj)

        cluster_id += 1

    return classes, cluster_id