Skip to main content

Translation-labeled periodic graphs on Z^d with exact component lattice invariants.

Project description

pbcgraph

CI Docs PyPI Python versions License: LGPL v3

pbcgraph is a compact Python library for translation-labeled periodic graphs on the integer lattice Z^d.

You store a finite quotient graph (internally a NetworkX MultiDiGraph), but every directed edge carries an integer translation vector. This gives the quotient an exact infinite-lift semantics and lets you do instance-aware connectivity tests without enumerating the infinite graph.

What you get in v0.1:

  • PeriodicGraph / PeriodicDiGraph: unique edge per (u, v, tvec).
  • PeriodicMultiGraph / PeriodicMultiDiGraph: parallel edges allowed for the same (u, v, tvec).
  • PeriodicComponent: lattice invariants (rank, SNF torsion) and exact instance connectivity via same_fragment(...).

Status

pbcgraph is alpha (v0.1). The core containers and component invariants are implemented and covered by tests. The API may still evolve, but the library is already useful for research code and prototyping.

Install

Requires Python 3.10+.

Once the project is published on PyPI:

python -m pip install pbcgraph

Until then (or for the latest dev branch), install from GitHub:

python -m pip install git+https://github.com/IvanChernyshov/pbcgraph.git

For local development:

python -m pip install -e ".[dev]"

Quickstart

from pbcgraph import PeriodicGraph

# A quotient graph in Z^2.
G = PeriodicGraph(dim=2)

# Undirected edges are stored internally as two directed realizations
# with tvec and -tvec.
G.add_edge('A', 'B', tvec=(0, 0))
G.add_edge('B', 'C', tvec=(0, 0))
G.add_edge('C', 'A', tvec=(1, 0))  # closes a periodic cycle (rank-1 along x)

# Lifted nodes are (node_id, cell_shift).
neighbors = list(G.neighbors_inst(('A', (0, 0))))

comp = G.components()[0]
assert comp.same_fragment(('A', (0, 0)), ('A', (1, 0)))
assert not comp.same_fragment(('A', (0, 0)), ('A', (0, 1)))

Documentation

Local docs build:

python -m pip install -e ".[docs]"
mkdocs serve

Notebooks in docs/examples/ are executed during mkdocs build (MkDocs + mkdocs-jupyter).

License

GNU LGPLv3 (or later). See LICENSE / COPYING.

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

pbcgraph-0.1.0.tar.gz (46.6 kB view details)

Uploaded Source

Built Distribution

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

pbcgraph-0.1.0-py3-none-any.whl (40.2 kB view details)

Uploaded Python 3

File details

Details for the file pbcgraph-0.1.0.tar.gz.

File metadata

  • Download URL: pbcgraph-0.1.0.tar.gz
  • Upload date:
  • Size: 46.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.19

File hashes

Hashes for pbcgraph-0.1.0.tar.gz
Algorithm Hash digest
SHA256 bc5f43e0b2fedd910c4f723964ecef1ee1fccec2c9b8d46946afed5a6542cb8f
MD5 ecbde6a9076edadb0e8cd6085ab20616
BLAKE2b-256 6cbcca52ac9d2761a99a802b360211774a3a4a151e710da96e15c8e311f24f22

See more details on using hashes here.

File details

Details for the file pbcgraph-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: pbcgraph-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 40.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.19

File hashes

Hashes for pbcgraph-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 573d9983c0bd35a72cf5f9464a335f0c7ba22c55659952a9bee4b645fa150ef9
MD5 90ede429b71e7f9274452bffb112a61a
BLAKE2b-256 90d269dcc476f518b4b5f780943383512db3ba2c709ca666a70753b262333184

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