Skip to main content

faster-or-curvature

PyPI version Downloads License

Exact Ollivier–Ricci curvature of every edge of an unweighted graph, with one minimum cut per edge, in exact integer arithmetic and without a distance matrix.

pip install faster-or-curvature        # imports as orcut

Any two vertices of the closed neighbourhoods of an edge are at distance at most three, so the Kantorovich dual of the edgewise transport problem has an integral optimum with potentials in {0, 1, 2, 3}. Written in unary, it is a maximum-weight closure, solved by one s–t minimum cut. Its arcs come from adjacency and common neighbours only (pairs at distance three give none), and with one relay node per common neighbour the network is linear in the adjacency lists of the vertices that carry net mass. The same holds for any one-step measures (lazy, non-lazy, any idleness, weighted walks), and, with 2r layers, for measures supported on balls of radius r.

import orcut
g = orcut.Graph.from_edges([(0, 1), (1, 2), (2, 0), (2, 3)])  # or a networkx graph / PyG Data
orcut.curvature(g)                      # lazy (idleness 1/(deg+1)), aligned with g.edges (u < v)
orcut.curvature(g, "lly")               # Lin–Lu–Yau; also "nonlazy", a number p (idleness p),
orcut.curvature(g, orcut.Walk(weights=w, idleness=0.5))   # or a weighted walk (integer weights)
orcut.curvature(g, exact_fraction=True) # also W1 as an exact integer fraction per edge
c = orcut.certify(g, (0, 1))            # an optimal plan and an optimal 1-Lipschitz potential
c.verified, c.verify(g)                 # checked exactly when built, and re-checkable from scratch
orcut.ball_curvature(g, 2)              # Ollivier's ball measures, radius 2 (layered closure)
orcut.walk_curvature(g, 2)              # two-step lazy random walk
orcut.affected_edges(g2, changed_pairs) # after inserting/deleting pairs: the only edges to recompute

Installation

Python 3.10 or later; numpy and numba come with it. From a clone, pip install -e ".[dev]" adds what the tests need (pytest, networkx, scipy), and pytest -q runs them.

Without a package index (for example on a cluster without PyPI access), copy the wheel over from a machine that has it:

pip download faster-or-curvature --no-deps -d wheels/                # where PyPI is reachable
conda install -c conda-forge "numpy>=2.2" "numba>=0.62"               # on the cluster
pip install --no-index --no-deps wheels/faster_or_curvature-*.whl

Versions

  • 1.2.0: witness relays (one zero-weight relay per common neighbour) for the pairs at distance 2 that the bitset network would list one by one, chosen per edge when the network gets smaller; a bound on the bitset work (four words per adjacency entry) beyond which an edge is solved on the linear-size witness network (orcut._witness, also usable on its own). Values unchanged (tested).
  • 1.1.0: orcut.curvature (any one-step measure, exact fractions, diagnostics, ablation flags), certificates (orcut.certify), the layered closure for supports of radius r (ball_curvature, walk_curvature), and exact incremental updates (affected_edges). The kernel of 1.0.0 is kept unchanged in orcut/_kernels.py, and orcut.curvature returns the same values bit for bit (tested).
  • 1.0.0 is the solver used for every exact curvature in Micaletto and Nigrelli, From Proxy to Certificate: Two-Sided Ollivier–Ricci Bounds from Balanced Forman Curvature: its compiled kernels (orcut/_kernels.py) are those of curvature_transfer.

Layout

Path Contents
orcut/graph.py CSR graph, canonical undirected edges, networkx / PyG / edge-list constructors
orcut/_kernels.py the 1.0.0 kernel (frozen): lazy, non-lazy, LLY, and the TLW certificate
orcut/_core.py the general one-step kernel: per-vertex masses, bitsets, relays, witness relays, ablation flags, diagnostics
orcut/_witness.py the linear-size witness network on its own (one relay per common neighbour; no bitsets, no distances)
orcut/_layered.py W1 on bounded integer metrics by a layered closure; ball and multi-step measures; certificates
orcut/measures.py measure specifications ("lazy", "nonlazy", "lly", idleness p, Walk)
orcut/certify.py per-edge certificates (plan and potential) and their exact verification
orcut/_reference.py independent oracle: full local distance matrix, three-level closure, recursive Dinic
orcut/api.py curvature, ball_curvature, walk_curvature, affected_edges, exact (1.0.0 API), thread control
tests/ kernels against each other (bit for bit), against the oracle, and against linear programming

Citation

A formal paper is currently in preparation and will be available on arXiv soon. In the meantime, if you use this software in your research, please cite the repository:

@misc{faster-or-curvature,
  author = {Giorgio Micaletto},
  title = {faster-or-curvature: Exact Ollivier–Ricci curvature in exact integer arithmetic},
  year = {2026},
  publisher = {GitHub},
  journal = {GitHub repository},
  howpublished = {\url{https://github.com/GiorgioMB/faster-or-curvature}},
}

Metadata

Release files for faster-or-curvature 1.2.1

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

Source distribution (sdist)

Source distribution for faster-or-curvature 1.2.1
File Size Uploaded Provenance Actions
faster_or_curvature-1.2.1.tar.gz 56.3 kB With provenance Details for faster_or_curvature-1.2.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for faster-or-curvature 1.2.1
File Interpreter ABI Platform Actions
faster_or_curvature-1.2.1-py3-none-any.whl Python 3 none any Details for faster_or_curvature-1.2.1-py3-none-any.whl

Total release size: 107.9 kB

Release files / faster_or_curvature-1.2.1.tar.gz

Download URL faster_or_curvature-1.2.1.tar.gz
Size 56.3 kB
Tags Source
SHA-256 checksum
How to use checksums
f33ff6990ad46dc22550fa9059137d61c41af8d1674326c70040892127141ff1
BLAKE2b-256 checksum
How to use checksums
95a7366bcc376e840ffe3bb4b1060260300ff2e3a045f0412505767af8bf89e2
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 9, 2026.

Transparency log

Release files / faster_or_curvature-1.2.1-py3-none-any.whl

Download URL faster_or_curvature-1.2.1-py3-none-any.whl
Size 51.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f41cfb8af7e9aec987c73f5f16b136a607fc22183a28c8db00595a7d3356953b
BLAKE2b-256 checksum
How to use checksums
b3e4daa06bb799d9a25e773564b1b344782663dc228fe97d55583909a4d3fa8b
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 9, 2026.

Transparency log

Security for faster-or-curvature 1.2.1

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

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for faster_or_curvature-1.2.1.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 9, 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