Skip to main content

Asunder

Asunder package banner

Asunder is a Python package for constrained network structure detection (constrained graph clustering) on undirected graphs. In other words, it partitions an undirected graph while respecting hard grouping rules. A node can represent a task, mathematical constraint, asset, location, or other item; an edge records a relationship between two nodes; and the result assigns every node to a community.

For example, Asunder can keep specified nodes together, prevent other nodes from sharing a community, and keep community sizes or workloads within chosen bounds. It also provides reusable column-generation tools for applications that need custom initial partitions, master problems, pricing, or refinement.

Development is led by Andrew Allman's Process Systems Research Team at the University of Michigan.

Asunder partitioning workflow

Install

Asunder supports Python 3.10 through 3.14 and is distributed on PyPI as put-asunder:

python -m pip install put-asunder
python -c "import asunder; print(asunder.__version__)"

The base installation includes NetworkX, NumPy, Pyomo, python-igraph, and leidenalg. Signed Leiden is the default pricing heuristic.

LoadBalancer, NonlinearBranchAndPrice, and the default reusable decomposition workflow require an available Pyomo-compatible optimization solver. Asunder selects Gurobi by default. Installing gurobipy does not provide a Gurobi license, so configure a working local, WLS, or other supported license before running those workflows. See the installation guide for a solver check and alternative-solver setup.

Optional extras are available for visualization and legacy core-periphery heuristics:

python -m pip install "put-asunder[viz]"
python -m pip install "put-asunder[legacy]"

The legacy extra is best-effort on Python 3.13 and 3.14. Current high-level workflows do not require it.

Choose a workflow

Goal Start with Solver required?
Create a fixed number of balanced or explicitly bounded communities asunder.load_balancing.LoadBalancer Yes
Use the NLBNP structural shortcut to isolate one linear-only group and recover independent communities asunder.nlbnp.CorePeripheryPartition No
Run the packaged nonlinear branch-and-price workflow asunder.nlbnp.NonlinearBranchAndPrice Yes
Replace initial columns, master logic, pricing, or refinement asunder.run_csd_decomposition Yes with the default master
Refine an existing partition with extensible hard constraints asunder.refine_partition_modular_vfd No

If you are unsure, start with the problem-fit and workflow-choice guide.

Choose a pricing algorithm

Algorithm / backend Use Signed edge weights GPU
Signed Leiden / leidenalg (default) General pricing Yes No
Louvain / NetworkX Unsigned pricing Clipped to zero Via nx-cugraph
Leiden / NetworkX Pricing with an activated Leiden backend Clipped to zero Via nx-cugraph
QMETIS Native load-balancing pricing Clipped to zero No

NetworkX Leiden requires a compatible NetworkX version and an activated backend, such as nx-cugraph. QMETIS scales and rounds edge weights for its search. Candidates are rescored using the original weights and master duals. Node loads in the built-in load-balancing workflow must be positive integers.

See the full algorithm comparison for objectives, weight support, and theoretical scalability.

Load-balancing quickstart

LoadBalancer is the most direct workflow when communities must have similar node counts or total node loads. This complete example requires a configured solver. It asks for two nearly equal communities, keeps "a" and "b" together, and prevents "a" and "f" from sharing a community.

from collections import defaultdict

import networkx as nx

from asunder.load_balancing import LoadBalancer

graph = nx.Graph(
    [
        ("a", "b"),
        ("a", "c"),
        ("b", "c"),
        ("c", "d"),
        ("d", "e"),
        ("d", "f"),
        ("e", "f"),
    ]
)

result = LoadBalancer(
    graph,
    K=2,
    R=1,
    must_link=[("a", "b")],
    cannot_link=[("a", "f")],
    final_master_solve=True,
    disable_tqdm=True,
)

groups = defaultdict(list)
for node, community in result.metadata["community_map_labels"].items():
    groups[community].append(node)

print(dict(groups))
print("community loads:", result.metadata["community_balance_weights"])
print("modularity:", result.metadata["modularity"])

The numeric community labels are arbitrary; what matters is which nodes share a label. result.final_partition is an N x N binary co-membership matrix in the graph's node iteration order. It may be a dense Boolean array or a SciPy CSR matrix, while retaining that same logical shape. Entry [i, j] is one when nodes i and j belong to the same community. The label-aware metadata maps that matrix back to the original NetworkX node labels.

Common controls include:

  • K and R for the number of communities and the width of their permitted load range;
  • R_bounds=(lower, upper) for explicit inclusive community-load bounds, with initialization and default refinement searching admissible community counts (wide bounds can increase search time);
  • node_weight_attr="load" to balance a positive integer node attribute instead of node count;
  • contract_graph=True to contract must-linked nodes while preserving their summed balance weights;
  • resolution to change modularity resolution; and
  • refine, use_refined_column, refine_post_loop, check_flat_pricing, and stopping_window to control refinement and termination on large inputs.

Signed Leiden is the default pricing backend. QMETIS is an optional native pricing heuristic selected with algorithm="qmetis" on a supported platform. Its platform and approximation details are kept in the QMETIS reference.

LoadBalancer raises ValueError for malformed inputs or impossible bound definitions. It raises RuntimeError if the search does not produce an integral feasible partition. Check bounds and pairwise constraints first, then consider a larger search budget or projection_repair=True.

See the complete load-balancing guide for weighted examples, result fields, and runtime controls.

NLBNP structural workflows

CorePeripheryPartition is an NLBNP-specific shortcut for a constraint graph; it is not presented as a general-purpose core-periphery partitioner. In its intended use, the supplied grouping constraints collect the nonlinear nodes into one detection block on the core side. The complementary periphery contains only linear nodes. All of those periphery nodes are merged into final community 0, even when they are disconnected, which supplies the NLBNP requirement that there be exactly one linear-only community.

The workflow then temporarily excludes that linear-only community from the original input graph and computes connected components of the remaining nonlinear/core-side induced subgraph, adding any supplied nonedge must_link pairs as virtual edges. It does not perform this final component split on the contracted detection graph. Those components are the independent communities; all temporarily excluded nodes remain present in the returned labels and metadata.

When must_group identifies designated nonlinear nodes, the workflow verifies that they were detected on the core side. It raises RuntimeError rather than returning a partition with the nonlinear block in the linear-only community.

Use this solver-free shortcut only when that NLBNP structure is appropriate and the exposed components are already the desired independent communities. Use NonlinearBranchAndPrice when the structural shortcut is insufficient and the constraint graph needs the packaged column-generation workflow.

NonlinearBranchAndPrice requires at least one worthy edge from the input graph; without an active edge rule, the problem is no longer NLBNP. It has three cardinality modes. The default, cardinality_method="reformulated", finds the exact maximum linear-only set, reduces the result to pairwise constraints, and enforces them alongside the edge-based constraint using column generation. An explicit cannot-link inside that set is reported as infeasible. The "confidence" and "core_periphery" modes first enforce the edge-based constraint and then detect the linear-only group using confidence-score clustering and core-periphery detection, respectively. All modes require the nonlinear nodes, supplied directly or by a NetworkX node attribute.

The NLBNP workflow guide contains complete examples and explains how the three modes differ.

Reusable decomposition and custom constraints

Use run_csd_decomposition when you need Asunder's orchestration but want to supply or replace initial columns, the master problem, pricing, or refinement. The reusable decomposition guide defines those terms and provides a complete example.

ModularVFD refinement supports pairwise, component-local, community-wide, and partition-wide hard constraints. Its constraint-extension guide shows how to implement them. A ModularVFD constraint governs ModularVFD refinement only unless the same rule is also enforced in initial-column generation, pricing, the master formulation, warm starts, and final validation.

For large sparse inputs, reusable decomposition and NLBNP preserve CSR through preprocessing and compatible pricing. Hard columns use dense Boolean or CSR Boolean storage according to measured density. Dense-only backends are guarded by a configurable estimated working-set limit; see the matrix-storage reference.

Documentation and examples

Asunder does not automatically convert an optimization model into a graph. The user supplies a NetworkX graph, an adjacency matrix, or application code that constructs one. Before tuning algorithms, confirm that node identity, edge meaning, edge weights, and hard constraints accurately represent the problem.

Metadata

Release files for put-asunder 0.4.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for put-asunder 0.4.2
File Size Uploaded Provenance Actions
put_asunder-0.4.2.tar.gz 242.7 kB With provenance Details for put_asunder-0.4.2.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for put-asunder 0.4.2
File Interpreter ABI Platform Actions
put_asunder-0.4.2-py3-none-win_amd64.whl Python 3 none Windows x86-64 Details for put_asunder-0.4.2-py3-none-win_amd64.whl
put_asunder-0.4.2-py3-none-manylinux_2_34_x86_64.whl Python 3 none Linux glibc 2.34+ x86-64 Details for put_asunder-0.4.2-py3-none-manylinux_2_34_x86_64.whl
put_asunder-0.4.2-py3-none-macosx_11_0_universal2.whl Python 3 none macOS 11.0+ universal2 (ARM64, x86-64) Details for put_asunder-0.4.2-py3-none-macosx_11_0_universal2.whl

Total release size: 1.9 MB

Release files / put_asunder-0.4.2.tar.gz

Download URL put_asunder-0.4.2.tar.gz
Size 242.7 kB
Tags Source
SHA-256 checksum
How to use checksums
8c7462812064cf9571a9deebec7fbebe359e1761be442745d35b4d4b7dd89941
BLAKE2b-256 checksum
How to use checksums
72c4cd5c990f11cbf40ee4a01a26442a45e7ac83dc37e4d8c63d0f09e00b31e6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 24, 2026.

Transparency log

Release files / put_asunder-0.4.2-py3-none-win_amd64.whl

Download URL put_asunder-0.4.2-py3-none-win_amd64.whl
Size 486.7 kB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
65fdc94afd39f48d72d897d418f88db2f6d36b5896dd2d7eaaa679b78c7df379
BLAKE2b-256 checksum
How to use checksums
a372dfc49ea89d0140e3dd3311ddbf5856560d947244cd555fca122a183a33f1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 24, 2026.

Transparency log

Release files / put_asunder-0.4.2-py3-none-manylinux_2_34_x86_64.whl

Download URL put_asunder-0.4.2-py3-none-manylinux_2_34_x86_64.whl
Size 480.3 kB
Tags Linux glibc 2.34+ x86-64 Python 3
SHA-256 checksum
How to use checksums
bae2c392669d5617203156544a7464d5905119bc1ebf54b62a8f8c0ab270111c
BLAKE2b-256 checksum
How to use checksums
968a8906ee1d8f19971e33a2fd6b36d2e2dc0747c02342307ba5d14ee015f3bf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 24, 2026.

Transparency log

Release files / put_asunder-0.4.2-py3-none-macosx_11_0_universal2.whl

Download URL put_asunder-0.4.2-py3-none-macosx_11_0_universal2.whl
Size 712.7 kB
Tags Python 3 macOS 11.0+ universal2 (ARM64, x86-64)
SHA-256 checksum
How to use checksums
1e2967943637f86f2353774440fb0c3635b826b7f5f9d6d84823bba9245024ae
BLAKE2b-256 checksum
How to use checksums
ab246d517052138d6cf75c8c8b3ad16a3f70c1d0a5e9f539eb4d1970fc6389a5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 24, 2026.

Transparency log

Security for put-asunder 0.4.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 4 files in this release have been uploaded with provenance metadata.

Select from 4 files

Attestation for put_asunder-0.4.2.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 24, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page