This is to partition a graph with Metis partitioning. Metis assigns vertices to partitions. This API constructs subgraphs with the vertices assigned to the partitions and their incoming edges. A subgraph may contain HALO nodes which does not belong to the partition of a subgraph but are
(
g,
k,
extra_cached_hops=0,
reshuffle=False,
balance_ntypes=None,
balance_edges=False,
mode="k-way",
)
| 398 | |
| 399 | |
| 400 | def metis_partition( |
| 401 | g, |
| 402 | k, |
| 403 | extra_cached_hops=0, |
| 404 | reshuffle=False, |
| 405 | balance_ntypes=None, |
| 406 | balance_edges=False, |
| 407 | mode="k-way", |
| 408 | ): |
| 409 | """This is to partition a graph with Metis partitioning. |
| 410 | |
| 411 | Metis assigns vertices to partitions. This API constructs subgraphs with the vertices assigned |
| 412 | to the partitions and their incoming edges. A subgraph may contain HALO nodes which does |
| 413 | not belong to the partition of a subgraph but are connected to the nodes |
| 414 | in the partition within a fixed number of hops. |
| 415 | |
| 416 | When performing Metis partitioning, we can put some constraint on the partitioning. |
| 417 | Current, it supports two constrants to balance the partitioning. By default, Metis |
| 418 | always tries to balance the number of nodes in each partition. |
| 419 | |
| 420 | * `balance_ntypes` balances the number of nodes of different types in each partition. |
| 421 | * `balance_edges` balances the number of edges in each partition. |
| 422 | |
| 423 | To balance the node types, a user needs to pass a vector of N elements to indicate |
| 424 | the type of each node. N is the number of nodes in the input graph. |
| 425 | |
| 426 | If `reshuffle` is turned on, the function reshuffles node IDs and edge IDs |
| 427 | of the input graph before partitioning. After reshuffling, all nodes and edges |
| 428 | in a partition fall in a contiguous ID range in the input graph. |
| 429 | The partitioend subgraphs have node data 'orig_id', which stores the node IDs |
| 430 | in the original input graph. |
| 431 | |
| 432 | The partitioned subgraph is stored in DGLGraph. The DGLGraph has the `part_id` |
| 433 | node data that indicates the partition a node belongs to. The subgraphs do not contain |
| 434 | the node/edge data in the input graph. |
| 435 | |
| 436 | Parameters |
| 437 | ------------ |
| 438 | g: DGLGraph |
| 439 | The graph to be partitioned |
| 440 | k: int |
| 441 | The number of partitions. |
| 442 | extra_cached_hops: int |
| 443 | The number of hops a HALO node can be accessed. |
| 444 | reshuffle : bool |
| 445 | Resuffle nodes so that nodes in the same partition are in the same ID range. |
| 446 | balance_ntypes : tensor |
| 447 | Node type of each node |
| 448 | balance_edges : bool |
| 449 | Indicate whether to balance the edges. |
| 450 | mode : str, "k-way" or "recursive" |
| 451 | Whether use multilevel recursive bisection or multilevel k-way paritioning. |
| 452 | |
| 453 | Returns |
| 454 | -------- |
| 455 | a dict of DGLGraphs |
| 456 | The key is the partition ID and the value is the DGLGraph of the partition. |
| 457 | """ |
no test coverage detected