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 Certificate: 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.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.4.0
File Size Uploaded Provenance Actions
faster_or_curvature-1.4.0.tar.gz 94.5 kB With provenance Details for faster_or_curvature-1.4.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for faster-or-curvature 1.4.0
File Actions
faster_or_curvature-1.4.0-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details for faster_or_curvature-1.4.0-cp310-abi3-win_amd64.whl
faster_or_curvature-1.4.0-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.0-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
faster_or_curvature-1.4.0-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.0-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
faster_or_curvature-1.4.0-cp310-abi3-macosx_10_12_universal2.macosx_10_12_x86_64.macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 11.0+ ARM64, macOS 10.12+ x86-64, macOS 10.12+ universal2 (ARM64, x86-64) Details for faster_or_curvature-1.4.0-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.0.tar.gz

Download URL faster_or_curvature-1.4.0.tar.gz
Size 94.5 kB
Tags Source
SHA-256 checksum
How to use checksums
a087ef829244f473f244e52dd7da96936bcd65f1bf5d2268c495a445275ee8cb
BLAKE2b-256 checksum
How to use checksums
88b9c74fe632aada9a9ca80efb87600e89235e6823a2a4a6335e6bb33e76a086
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 1, 2026.

Transparency log

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

Download URL faster_or_curvature-1.4.0-cp310-abi3-win_amd64.whl
Size 438.5 kB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
728cecf3bc9715d804fb8cb1acc05f8e2efebea7d6faae9734bc15910843471d
BLAKE2b-256 checksum
How to use checksums
2aa6670a1c8d94e50311942ebd25d57050e6d086b3c08a54a8e58a8f25c025a1
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 1, 2026.

Transparency log

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

Download URL faster_or_curvature-1.4.0-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
cc105ef2a3aac45423dabcef04938e165708fe5b90b9e8b616c901253ed094bd
BLAKE2b-256 checksum
How to use checksums
6002d315fb55bde49561776c565d648d0310b41f3c5a6933edb7b4971ccd8542
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 1, 2026.

Transparency log

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

Download URL faster_or_curvature-1.4.0-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 520.7 kB
Tags CPython 3.10 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
d8926e63d46fbc102ff07a857636151c35da8d2f62cb2039476db3c648b2fc9a
BLAKE2b-256 checksum
How to use checksums
381bed8d0c380d07c8ed95efb42e26c232a04188cd9c01e71935d8197ff9c6fd
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 1, 2026.

Transparency log

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

Download URL faster_or_curvature-1.4.0-cp310-abi3-macosx_10_12_universal2.macosx_10_12_x86_64.macosx_11_0_arm64.whl
Size 945.2 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
fe3e76bf8e4e397193c419d271e00aa1f2ff9318ad7460fa4c708cfb15211540
BLAKE2b-256 checksum
How to use checksums
8d4d5efce888b0ae00d42edb3dc66e8d6a14059982b07addb0417ca1a1c2b63f
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 1, 2026.

Transparency log

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

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

Select from 5 files

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