balanced_partition
¶
balanced_partition(
edge_index: Union[array, ndarray],
num_nodes: int,
num_parts: int,
num_iters: int = 10,
imbalance: float = 0.05,
) -> ndarray
Dependency-free balanced graph partitioning.
Nodes are ordered by a breadth-first traversal of the (undirected) graph,
the order is cut into num_parts chunks of equal size, and the
partitions are refined with balanced label propagation (a node moves to the
partition holding most of its neighbors while sizes stay within
imbalance of the average). Partitions are therefore connected-ish and
balanced, but their edge cut is usually worse than METIS'.
Randomness comes from np.random (seed it for reproducible partitions).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
edge_index
|
Union[array, ndarray]
|
|
required |
num_nodes
|
int
|
Number of nodes. |
required |
num_parts
|
int
|
Number of partitions. |
required |
num_iters
|
int
|
Number of label propagation rounds. Defaults to 10 |
10
|
imbalance
|
float
|
Allowed relative deviation of the partition sizes from the average during refinement. Defaults to 0.05 |
0.05
|
Returns:
| Type | Description |
|---|---|
ndarray
|
The partition id of every node, as a |
Source code in mlx_graphs/loaders/cluster.py
from mlx_graphs.loaders import balanced_partition · mlx_graphs/loaders/cluster.py