修正单元测试失败代码
This commit is contained in:
@@ -32,6 +32,13 @@ print(nodes_part_1)
|
||||
|
||||
|
||||
def calculate_district_metering_area_for_nodes(name: str, nodes: list[str], part_count: int = 1, part_type: int = PARTITION_TYPE_RB) -> list[list[str]]:
|
||||
if part_type != PARTITION_TYPE_RB and part_type != PARTITION_TYPE_KWAY:
|
||||
return []
|
||||
if part_count <= 0:
|
||||
return []
|
||||
elif part_count == 1:
|
||||
return [nodes]
|
||||
|
||||
topology = Topology(name, nodes)
|
||||
t_nodes = topology.nodes()
|
||||
t_links = topology.links()
|
||||
@@ -52,7 +59,16 @@ def calculate_district_metering_area_for_nodes(name: str, nodes: list[str], part
|
||||
adjacency_list.append(np.array(a_nodes))
|
||||
|
||||
recursive = part_type == PARTITION_TYPE_RB
|
||||
n_cuts, membership = pymetis.part_graph(nparts=part_count, adjacency=adjacency_list, recursive=recursive, contiguous=True)
|
||||
options = pymetis.Options()
|
||||
options.set_defaults()
|
||||
options._set(pymetis.OptionKey.CONTIG, 1)
|
||||
options._set(pymetis.OptionKey.SEED, 0)
|
||||
n_cuts, membership = pymetis.part_graph(
|
||||
nparts=part_count,
|
||||
adjacency=adjacency_list,
|
||||
recursive=recursive,
|
||||
options=options,
|
||||
)
|
||||
|
||||
result: list[list[str]] = []
|
||||
for i in range(0, part_count):
|
||||
|
||||
Reference in New Issue
Block a user