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 is the version described in The Min-Cut Formulation of Ollivier–Ricci Curvature (Giorgio Micaletto, arXiv, forthcoming); pip install faster-or-curvature==1.2.0 reproduces it. It adds 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, and 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.2.1 and 1.2.2 change documentation only.
  • 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

Version 1.2.0 is the version described in The Min-Cut Formulation of Ollivier–Ricci Curvature (Giorgio Micaletto), which will appear on arXiv. Until then, please cite the software:

@misc{faster-or-curvature,
  author       = {Giorgio Micaletto},
  title        = {faster-or-curvature: Exact Ollivier--Ricci curvature in exact integer arithmetic},
  year         = {2026},
  version      = {1.2.0},
  howpublished = {\url{https://github.com/GiorgioMB/faster-or-curvature}},
  note         = {Version 1.2.0, described in ``The Min-Cut Formulation of Ollivier--Ricci Curvature''},
}

GitHub's "Cite this repository" button gives the same entry, from CITATION.cff.

Metadata

Release files for faster-or-curvature 1.2.2

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.2
File Size Uploaded Provenance Actions
faster_or_curvature-1.2.2.tar.gz 57.2 kB With provenance Details for faster_or_curvature-1.2.2.tar.gz

Built distribution (wheel)

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

Total release size: 109.1 kB

Release files / faster_or_curvature-1.2.2.tar.gz

Download URL faster_or_curvature-1.2.2.tar.gz
Size 57.2 kB
Tags Source
SHA-256 checksum
How to use checksums
90695d81c9ac1574e702bb74bee907aba35aba073f7ed7680c0c6c05fd0ad46c
BLAKE2b-256 checksum
How to use checksums
de2bb70a1ad44c2c86fc3b95061b3df28f6e781f03255e0cf3d60faf50a68cfe
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 24, 2026.

Transparency log

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

Download URL faster_or_curvature-1.2.2-py3-none-any.whl
Size 51.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
be559be3ad13f109c928e035a7e22e7ba417083df875cbc69cb0a022edbef227
BLAKE2b-256 checksum
How to use checksums
cc044c840a05bae0b5c05dd7420036924c9d39c9ef33aaa71c776bce64bfe395
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 24, 2026.

Transparency log

Security for faster-or-curvature 1.2.2

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.2.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 24, 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