Refinement¶
Refinement routines specific to nonlinear branch-and-price workflows.
- asunder.nlbnp.algorithms.refinement.refine_partition_linear_group(A, partition, *, p=1, prob_method='threshold', threshold=0.8, verbose=False, seed=42)¶
Refine a partition by separating a linear-only group from the remaining nodes.
- Parameters:
A (ndarray of float, shape (N, N)) – Graph adjacency/weight matrix.
partition (ndarray of int, shape (N,) or (N, N)) – Predicted community labels or a 2D partition matrix.
p (int) – Order of the norm. Defaults to the L1 norm.
prob_method (str) – One of
"threshold","gaussian_mixture", or"DBSCAN".threshold (float) – Value below which a node is reassigned to the linear-only group.
verbose (bool) – Controls the verbosity of the output.
- Returns:
Refined 2D partition matrix.
- Return type:
ndarray of int, shape (N, N)
- asunder.nlbnp.algorithms.refinement.refine_partition_with_cp(A, partition, *, unworthy_edges=None, nonlinear_nodes=None, cp_algorithm='SPEC', prob_method='gaussian_mixture', threshold=0.8, verbose=False, seed=42)¶
Refine a partition by detecting and merging a standalone core community.
Existing periphery community assignments are preserved. All detected core nodes are assigned to one shared community.
- Parameters:
A (ndarray of float, shape (N, N)) – Graph adjacency/weight matrix.
partition (ndarray of int, shape (N,) or (N, N)) – Predicted community labels or a 2D partition matrix.
unworthy_edges (list[tuple[int, int]] or None) – Node pairs that must be linked because the edges between them cannot connect nodes in different communities.
nonlinear_nodes (list[int] | None) – Nodes that correspond to nonlinear constraints and so, should be merged.
cp_algorithm (str) – Core periphery algorithm to be used. Should be one of:
"SPEC": Continuous spectral core periphery detection"GA": Continuous genetic search for BE objective"KL": Continuous Kernighan-Lin algorithmprob_method (str) – One of
"threshold","gaussian_mixture", or"DBSCAN".threshold (float) – Value below which a node is reassigned to the linear-only group.
verbose (bool) – Controls the verbosity of the output.
seed (int | None) – Random seed value.
- Returns:
Refined 2D partition matrix.
- Return type:
ndarray of int, shape (N, N)