dgl.metis_partition_assignment
- dgl.metis_partition_assignment(g, k, balance_ntypes=None, balance_edges=False, mode='k-way', objtype='cut')[source]
这使用Metis分区算法将节点分配到不同的分区。
在执行Metis分区时,我们可以在分区上施加一些约束。 目前,它支持两种约束来平衡分区。默认情况下,Metis 总是尝试平衡每个分区中的节点数量。
balance_ntypes balances the number of nodes of different types in each partition.
balance_edges balances the number of edges in each partition.
为了平衡节点类型,用户需要传递一个包含N个元素的向量来指示每个节点的类型。N是输入图中节点的数量。
分区分配后,我们构建分区。
- Parameters:
g (DGLGraph) – The graph to be partitioned
k (int) – The number of partitions.
balance_ntypes (tensor) – Node type of each node
balance_edges (bool) – Indicate whether to balance the edges.
mode (str, "k-way" or "recursive") – Whether use multilevel recursive bisection or multilevel k-way paritioning.
objtype (str, "cut" or "vol") – Set the objective as edge-cut minimization or communication volume minimization. This argument is used by the Metis algorithm.
- Returns:
一个向量,每个元素表示顶点的分区ID。
- Return type:
一个一维张量