Graph partitioning algorithms using random spanning trees
Project description
Partigraph
Graph partitioning algorithms using random spanning trees.
Partigraph implements algorithms for partitioning graphs into districts of approximately equal weight. It uses random spanning trees to find transfer moves between partitions and iteratively improve divisions to meet weight constraints.
Features
- Uniform Random Spanning Trees: Implementation of Wilson's algorithm for generating uniformly random spanning trees
- Weight-Balanced Partitioning: Divide graphs into districts with configurable weight constraints
- Iterative Improvement: Refine partitions through random spanning tree-based transfers
- Flexible Weight Functions: Support for custom node weight functions or node attributes
Installation
pip install partigraph
Algorithm
Partigraph uses a divide-and-conquer approach:
- Generate a random spanning tree of the graph using Wilson's algorithm
- Find the edge cut that best divides the graph into the target weights
- Recursively partition each side
- Iteratively improve the partition by finding beneficial transfers between districts
The random spanning tree approach ensures good connectivity properties and helps avoid gerrymandering-like artifacts.
Requirements
- Python >= 3.12
- NetworkX
License
MIT License - see LICENSE file for details
References
Wilson's algorithm for uniform random spanning trees:
- Wilson, D. B. (1996). "Generating Random Spanning Trees More Quickly than the Cover Time"
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file partigraph-0.1.0.tar.gz.
File metadata
- Download URL: partigraph-0.1.0.tar.gz
- Upload date:
- Size: 12.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a16689f46cc84261e519465cfa506fbaf15eb6beaad8517a779748605df919ec
|
|
| MD5 |
c628d263147baa25a34801fcd5709001
|
|
| BLAKE2b-256 |
0295d44293431e9fc2cac97d87acacd751fa20dc2603e0f29c644416893384f9
|
File details
Details for the file partigraph-0.1.0-py3-none-any.whl.
File metadata
- Download URL: partigraph-0.1.0-py3-none-any.whl
- Upload date:
- Size: 13.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fe2b097469e85f7f2797033518a1364b8234e0637ec60d226bbf67eb4e116ee3
|
|
| MD5 |
dbd0bb59a5f234087047fab6a898c2a4
|
|
| BLAKE2b-256 |
4d7ec53e7686a25a04971f710ef96ecb2ffb653a7b0820f2108ae9386fb71fd0
|