Skip to main content

faster-or-curvature

PyPI version Downloads License

Exact Ollivier–Ricci curvature of every edge of a graph, with one minimum cut per edge, in exact integer arithmetic and without a distance matrix; also for weighted walks and edge lengths. A native backend (Rust) computes it on all cores with no JIT warm-up.

pip install faster-or-curvature        # imports as orcut
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", or a number p (idleness p)
orcut.curvature(g, orcut.Walk(weights=w, idleness=0.5))   # a weighted walk (any positive 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
orcut.curvature(g, lengths=l)           # edge lengths: 1 - W1 / d(i, j), d the weighted distance
orcut.curvature(g, lengths=l, truncation=3)  # real lengths, 3 decimals kept: exact fractions
orcut.curvature(G, lengths="weight")    # with a networkx graph, an edge attribute name

Any two vertices of the closed neighbourhoods of an edge are at distance at most three, so the Kantorovich dual of its transport problem has an integral optimum with potentials in {0, 1, 2, 3}: in unary, a maximum-weight closure, solved by one minimum cut whose arcs come from adjacency and common neighbours only. Walk weights only change the capacities of that cut: integer weights are exact, real weights run in floating point. Integer edge lengths keep an integral optimum, so the transport problem is still one minimum cut, on D − 1 layers; with real lengths, each edge's transport problem is solved by a network simplex in floating point (truncation=k keeps k decimal digits and is exact on the truncated metric).

Against GraphRicciCurvature 0.6.1 (exact transport, method="OTD", one process) on real weighted networks, with the same values to 1e-13 on every edge (seconds on one core; lazy walk with idleness 1/2, or its default heat kernel exp(-w^2) with lengths divided by their median):

network edges measure faster-or-curvature GraphRicciCurvature
Les Misérables (length 1/co-occurrences) 254 uniform / heat 0.0043 / 0.0039 0.069 / 0.059
OpenFlights airports, 6 nearest neighbours (km) 11636 uniform / heat 0.16 / 0.17 3.7 / 3.9
OpenFlights routes (great-circle km) 18833 uniform 5.4 14.0

The native backend (orcut._native) is a port of the numba kernel of orcut._core and returns the same values bit for bit; backend="auto" uses it when installed, except for diagnostics and the ablation flags of the numba kernel, which also computes certificates and ball and multi-step measures. PyPI has wheels for Linux, macOS and Windows (Python ≥ 3.10); building from source needs a Rust toolchain: pip install -e ".[dev]", then pytest -q.

Versions

1.3.0 adds the native backend, real walk weights and edge lengths; 1.3.1 changes no result, nor does 1.3.2, which removes orcut.exact, exact_ids, exact_or_ids and N_EXACT with the frozen kernel behind them (orcut.curvature returns the same values). 1.2.2 is the version described in The Min-Cut Formulation of Ollivier–Ricci Curvature: it contains the solver of orcut 1.4.4, as do 1.2.0 and 1.2.1, which differ from it in documentation only. Details: CHANGELOG.md.

Layout

Path Contents
orcut/_core.py the one-step kernel: bitsets, relays, witness relays, twin merging, warm-started Dinic
orcut/_witness.py the linear-size witness network (one relay per common neighbour)
orcut/_layered.py W1 on bounded integer metrics by a layered closure: balls, multi-step walks
orcut/certify.py certificates (an optimal plan and potential), checked exactly
orcut/weighted.py, _backend.py edge lengths; the calls into the native backend
orcut/_flow.py integer constants, arenas, bitsets, CSR networks and Dinic's maximum flow, shared by the kernels
orcut/_oracle.py the oracle: explicit distances, three-level closure, its own max flow
orcut/api.py, graph.py, measures.py entry points, CSR graphs, measures
src/ the native backend: hop.rs (port of _core), lengths.rs, flow.rs, nbhd.rs, lib.rs
tests/ kernels against each other (bit for bit), the oracle and linear programming

Citation

If you use faster-or-curvature, please cite the paper that describes it (version 1.2.2 is the version described there):

@misc{micaletto2026mincut,
  author        = {Giorgio Micaletto},
  title         = {The Min-Cut Formulation of {Ollivier--Ricci} Curvature},
  year          = {2026},
  eprint        = {2611.32528},
  archivePrefix = {arXiv},
  primaryClass  = {cs.DS},
  doi           = {10.48550/arXiv.2611.32528},
  url           = {https://arxiv.org/abs/2611.32528},
}

GitHub's "Cite this repository" points to the same paper, from CITATION.cff.

Metadata

Release files for faster-or-curvature 1.3.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.3.2
File Size Uploaded Provenance Actions
faster_or_curvature-1.3.2.tar.gz 85.8 kB With provenance Details for faster_or_curvature-1.3.2.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for faster-or-curvature 1.3.2
File Actions
faster_or_curvature-1.3.2-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details for faster_or_curvature-1.3.2-cp310-abi3-win_amd64.whl
faster_or_curvature-1.3.2-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl CPython 3.10 abi3 Linux glibc 2.17+ x86-64 Details for faster_or_curvature-1.3.2-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
faster_or_curvature-1.3.2-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl CPython 3.10 abi3 Linux glibc 2.17+ ARM64 Details for faster_or_curvature-1.3.2-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
faster_or_curvature-1.3.2-cp310-abi3-macosx_10_12_universal2.macosx_10_12_x86_64.macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 10.12+ universal2 (ARM64, x86-64), macOS 11.0+ ARM64, macOS 10.12+ x86-64 Details for faster_or_curvature-1.3.2-cp310-abi3-macosx_10_12_universal2.macosx_10_12_x86_64.macosx_11_0_arm64.whl

Total release size: 2.4 MB

Release files / faster_or_curvature-1.3.2.tar.gz

Download URL faster_or_curvature-1.3.2.tar.gz
Size 85.8 kB
Tags Source
SHA-256 checksum
How to use checksums
19b2057eeef9355118ed03b6dad09c990af2153c3f0bf9671009b4e126dda14b
BLAKE2b-256 checksum
How to use checksums
0afd9e2aac7fa170870f35c3f4beb8128eb6877fd22a26201ffde44f0449fba1
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 27, 2026.

Transparency log

Release files / faster_or_curvature-1.3.2-cp310-abi3-win_amd64.whl

Download URL faster_or_curvature-1.3.2-cp310-abi3-win_amd64.whl
Size 397.4 kB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
c8ef4951c663fdd632936852dbfbcfa25bbe5a2b3c690d326d0c48e3acb3be10
BLAKE2b-256 checksum
How to use checksums
81034dbf262ca648384ad824044de48096d6fd843ca6345a8df24d1ce4a3ed34
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 27, 2026.

Transparency log

Release files / faster_or_curvature-1.3.2-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL faster_or_curvature-1.3.2-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 506.0 kB
Tags CPython 3.10 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
9d1a75c4199911433f0903cc2fca897b82d9896201c0059cc0232471e23680a8
BLAKE2b-256 checksum
How to use checksums
7325287955cd99434e8295f245ed4dc62ddbd86ea23a817bfaad7a445eea12a5
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 27, 2026.

Transparency log

Release files / faster_or_curvature-1.3.2-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

Download URL faster_or_curvature-1.3.2-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 487.5 kB
Tags CPython 3.10 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
03100c968a067f719822d405aafcbae95c1f8a91adb30aec557cc5324b21b47c
BLAKE2b-256 checksum
How to use checksums
41f7542e0db7ab49769ba119fab31ebc3d607dcc8bba5cf9e72849bf2b79cea4
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 27, 2026.

Transparency log

Release files / faster_or_curvature-1.3.2-cp310-abi3-macosx_10_12_universal2.macosx_10_12_x86_64.macosx_11_0_arm64.whl

Download URL faster_or_curvature-1.3.2-cp310-abi3-macosx_10_12_universal2.macosx_10_12_x86_64.macosx_11_0_arm64.whl
Size 875.7 kB
Tags CPython 3.10 abi3 macOS 10.12+ universal2 (ARM64, x86-64) macOS 10.12+ x86-64 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
775a5910fc69a84f312b4afb4ca4b4fe551a91207980126cac42a28720a7ea8a
BLAKE2b-256 checksum
How to use checksums
cc54fa53d39bb0f3c35d7907fb9e717c297c611490a925a5970612b3fa0016d7
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 27, 2026.

Transparency log

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

All 5 files in this release have been uploaded with provenance metadata.

Select from 5 files

Attestation for faster_or_curvature-1.3.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 27, 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