Skip to main content

PGMST

Physics-informed Graph embedding + Multi-objective ST (MST-based) regionalization.

Two-stage API:

  1. pgmst.pgnn.PGNN — packaged SGCN pipeline (half-life OD weights + spatial glue on contiguity edges). embed() appends Emb_X / Emb_Y to your zone table.
  2. pgmst.mst.MST — build an MST on the spatial adjacency graph with edge costs from embedding distance, then modularity- and constraint-driven partitioning (population / hospital / custom caps, minimum localization index).

Optional: GCN-style embedding via pgmst.physics_graph + PyTorch Geometric (see example notebook).

Install

pip install pgmst

For a development editable install from a clone:

pip install -e ".[dev]"

Quick start

from pgmst import PGNN, MST

coords_emb = PGNN(
    coords_df,
    df_flow,
    id_column="ZoneID",
    w=df_adj,
    k_hops=5,
    w_adj_percentile=75.0,
    coordxy="XCoord,YCoord",
).embed()

pr = MST(
    coords_emb,
    df_flow,
    id_column="ZoneID",
    emb=("Emb_X", "Emb_Y"),
    w=df_adj,
    constraints=[("POPU", "min", 10_000), ("POPU", "max", 500_000), ("hosp", "min", 1)],
    min_local_index=0.3,
).partition()

print(pr.modularity)
print(pr.cluster.head())

Example notebook

After installation, the Florida demo notebook is shipped inside the package:

  • pgmst/examples/PGMST_Florida_demo.ipynb

You can copy it to your working directory or open it from site-packages/pgmst/examples/.
The notebook expects OD/adjacency/shapefile paths: point REPO at a checkout of GNNGeoCommunity (or your own data) where data/OD_All_Flows30K.csv, data/FLAdjUpdate.csv, and data/Florida_2011.zip live.

PyPI release

See docs/PYPI.md for local builds (python -m build / twine) and GitHub Actions publishing (Trusted Publisher on PyPI).

Requirements

Python 3.10+, PyTorch, PyTorch Geometric, GeoPandas, NetworkX, SciPy, pandas, NumPy. Queen/Rook contiguity needs libpysal.

License

MIT — see LICENSE.

Metadata

Release files for pgmst 0.2.0

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

Source distribution (sdist)

Source distribution for pgmst 0.2.0
File Size Uploaded Provenance Actions
pgmst-0.2.0.tar.gz 10.5 MB Without provenance Details for pgmst-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pgmst 0.2.0
File Interpreter ABI Platform Actions
pgmst-0.2.0-py3-none-any.whl Python 3 none any Details for pgmst-0.2.0-py3-none-any.whl

Total release size: 10.7 MB

Release files / pgmst-0.2.0.tar.gz

Download URL pgmst-0.2.0.tar.gz
Size 10.5 MB
Tags Source
SHA-256 checksum
How to use checksums
87776fe5799c6ae2d528adcb0797d743c86cdd95757c6be9bec12fd704e337b0
BLAKE2b-256 checksum
How to use checksums
b9dae14d4c6a6aa098134e3ff0fef11f3ae8063d0a1d7455f069b8b7ea29eded
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.4

Release files / pgmst-0.2.0-py3-none-any.whl

Download URL pgmst-0.2.0-py3-none-any.whl
Size 144.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e69ac664728e224a2961ab33e133254c2fde33622d753703296eab955f8ece9b
BLAKE2b-256 checksum
How to use checksums
13f7d1c3659d812685a739d896aaf976d00aec197abdd0e8dddc9fc0015d26f2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.4

Security for pgmst 0.2.0

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files No provenance

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