Skip to main content

faster-or-curvature

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, What Balanced Forman Curvature Certifies About Ollivier–Ricci 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

Metadata

Release files for faster-or-curvature 1.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 faster-or-curvature 1.2.0
File Size Uploaded Provenance Actions
faster_or_curvature-1.2.0.tar.gz 55.8 kB With provenance Details for faster_or_curvature-1.2.0.tar.gz

Built distribution (wheel)

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

Total release size: 107.0 kB

Release files / faster_or_curvature-1.2.0.tar.gz

Download URL faster_or_curvature-1.2.0.tar.gz
Size 55.8 kB
Tags Source
SHA-256 checksum
How to use checksums
e71965b64d844a55a319ecb7c444879bbd763f224d3803da539df7e9fb393708
BLAKE2b-256 checksum
How to use checksums
63931371d2465e109e1c441adcbd9335ed4179ebd4dd84f87e9924060dac25b1
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 Oct 30, 2026.

Transparency log

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

Download URL faster_or_curvature-1.2.0-py3-none-any.whl
Size 51.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4b31870f248a50620eb4e2e31b60b95d631ef364525fa2ea6585391e6c10f86e
BLAKE2b-256 checksum
How to use checksums
3774a613e5f43a7db37b56702d1b7daa0592fece09d204e3d095ce7116877c3a
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 Oct 30, 2026.

Transparency log

Security for faster-or-curvature 1.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.

Full provenance

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

Select from 2 files

Attestation for faster_or_curvature-1.2.0.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 Oct 30, 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