Skip to main content

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:

  1. Generate a random spanning tree of the graph using Wilson's algorithm
  2. Find the edge cut that best divides the graph into the target weights
  3. Recursively partition each side
  4. 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

partigraph-0.1.0.tar.gz (12.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

partigraph-0.1.0-py3-none-any.whl (13.1 kB view details)

Uploaded Python 3

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

Hashes for partigraph-0.1.0.tar.gz
Algorithm Hash digest
SHA256 a16689f46cc84261e519465cfa506fbaf15eb6beaad8517a779748605df919ec
MD5 c628d263147baa25a34801fcd5709001
BLAKE2b-256 0295d44293431e9fc2cac97d87acacd751fa20dc2603e0f29c644416893384f9

See more details on using hashes here.

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

Hashes for partigraph-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fe2b097469e85f7f2797033518a1364b8234e0637ec60d226bbf67eb4e116ee3
MD5 dbd0bb59a5f234087047fab6a898c2a4
BLAKE2b-256 4d7ec53e7686a25a04971f710ef96ecb2ffb653a7b0820f2108ae9386fb71fd0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page