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
orcut.tq_bound(g)                       # a two-sided bound per edge, in exact integers (lazy measure)
orcut.screen(g, 0)                      # the edges with kappa < 0, exactly: the bound decides most
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. It also computes the triangle-quadrangle bound, screen-then-solve and Balanced Forman curvature (orcut.tq_bound, orcut.screen, orcut.balanced_forman), which have no numba counterpart and need it. 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.4.0 adds the triangle-quadrangle bound (orcut.tq_bound), screen-then-solve (orcut.screen) and Balanced Forman curvature (orcut.balanced_forman) to the native backend, and changes no other result. 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, tq.rs (the triangle-quadrangle bound and Balanced Forman curvature), lib.rs
tests/ kernels against each other (bit for bit), the oracle and linear programming; the bound, screen-then-solve and Balanced Forman curvature against exact curvature and their definitions (test_tq.py)

Citation

If you use faster-or-curvature, please cite the preprint 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},
}

orcut.tq_bound, orcut.screen and orcut.balanced_forman implement a second preprint; if you use them, please also cite it:

@misc{micaletto2026proxy,
  author        = {Giorgio Micaletto and Tebe Nigrelli},
  title         = {From Proxy to Guarantee: Two-Sided {Ollivier--Ricci} Bounds from {Balanced Forman} Curvature},
  year          = {2026},
  eprint        = {2603.13535},
  archivePrefix = {arXiv},
  primaryClass  = {stat.CO},
  doi           = {10.48550/arXiv.2603.13535},
  url           = {https://arxiv.org/abs/2603.13535},
}

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

Metadata

Release files for faster-or-curvature 1.4.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.4.1
File Size Uploaded Provenance Actions
faster_or_curvature-1.4.1.tar.gz 94.7 kB With provenance Details for faster_or_curvature-1.4.1.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for faster-or-curvature 1.4.1
File Actions
faster_or_curvature-1.4.1-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details for faster_or_curvature-1.4.1-cp310-abi3-win_amd64.whl
faster_or_curvature-1.4.1-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.4.1-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
faster_or_curvature-1.4.1-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl CPython 3.10 abi3 Linux glibc 2.17+ ARM64 Details for faster_or_curvature-1.4.1-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
faster_or_curvature-1.4.1-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.4.1-cp310-abi3-macosx_10_12_universal2.macosx_10_12_x86_64.macosx_11_0_arm64.whl

Total release size: 2.5 MB

Release files / faster_or_curvature-1.4.1.tar.gz

Download URL faster_or_curvature-1.4.1.tar.gz
Size 94.7 kB
Tags Source
SHA-256 checksum
How to use checksums
acd7bd2815ea8aaf8e4104d99ce57f8784080c6a610ca2e79882543155c10a3d
BLAKE2b-256 checksum
How to use checksums
6fd03b5fbe0732fc1f7678e83ac93a8887aa6a21fb97caee830c7e3b37e0edb4
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 Dec 2, 2026.

Transparency log

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

Download URL faster_or_curvature-1.4.1-cp310-abi3-win_amd64.whl
Size 438.5 kB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
6002acf5f99a3fbc1f3c9add5dc6759c1a8ada190798ab99e3040a579f0786ae
BLAKE2b-256 checksum
How to use checksums
4ba2e6bc5e0733a49d2e266addbd1f4ffa512d4706080d0264746bdfc2690bac
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 Dec 2, 2026.

Transparency log

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

Download URL faster_or_curvature-1.4.1-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 545.4 kB
Tags CPython 3.10 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
dff0f2f0a7784ab06cd5273fdeb4bb7ffca87d6be8985d3d219e5bee0db99db8
BLAKE2b-256 checksum
How to use checksums
f9536d47050876a47468fc86d07e249bb152978b3565bc65476453b1c0082d38
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 Dec 2, 2026.

Transparency log

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

Download URL faster_or_curvature-1.4.1-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 520.8 kB
Tags CPython 3.10 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
692985ac0ce18d7df13e231370f1653148ccddf6bd6457c272b0d28d75eecc41
BLAKE2b-256 checksum
How to use checksums
460bc237a874a44c0b2e3a71049d7a6de64d4b4dc864654635771ef0f7c6a072
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 Dec 2, 2026.

Transparency log

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

Download URL faster_or_curvature-1.4.1-cp310-abi3-macosx_10_12_universal2.macosx_10_12_x86_64.macosx_11_0_arm64.whl
Size 945.3 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
37b2ecfe2a87138afe14175045b27a6885e3a4f5e20e8c6197beff7b4d7b9644
BLAKE2b-256 checksum
How to use checksums
a8683276bf2967df0e7ef80010828753fb85c6823f250226deb87a8fdc8d2f41
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 Dec 2, 2026.

Transparency log

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

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

Select from 5 files

Attestation for faster_or_curvature-1.4.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 Dec 2, 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