def idx_from_cluster_idx(cluster_idx, idx_in_cluster, cluster_size):
    """
    Helper function for stochastic block models.

    Given a cluster number and the index of a vertex inside the cluster, get the index of this vertex in the entire
    graph.

    Everything is 0-indexed.

    :param cluster_idx: the index of the cluster containing the vertex.
    :param idx_in_cluster: the index of the vertex within the cluster
    :param cluster_size: the size of each cluster
    :return: the index of the vertex in the entire graph
    """
    return (cluster_size * cluster_idx) + idx_in_cluster