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, ball and multi-step measures, and the frozen 1.0.0 kernel. 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. 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. The kernel of 1.0.0 is kept unchanged in orcut/_kernels.py (orcut.exact). 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/_kernels.py the 1.0.0 kernel, frozen
orcut/_reference.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

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

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

Metadata

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

Built distributions (wheels)

Table of built distributions (wheels) for faster-or-curvature 1.3.1
File Actions
faster_or_curvature-1.3.1-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details for faster_or_curvature-1.3.1-cp310-abi3-win_amd64.whl
faster_or_curvature-1.3.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.3.1-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
faster_or_curvature-1.3.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.3.1-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
faster_or_curvature-1.3.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.3.1-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.1.tar.gz

Download URL faster_or_curvature-1.3.1.tar.gz
Size 92.7 kB
Tags Source
SHA-256 checksum
How to use checksums
3bc035a1815efc36ec4f19f48831a98951272f62b424833324f379f887bcd31b
BLAKE2b-256 checksum
How to use checksums
41f9437f76b62506291ff30849a660e937a06ba5acd6d4872f6c84a50be6b786
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.3.1-cp310-abi3-win_amd64.whl

Download URL faster_or_curvature-1.3.1-cp310-abi3-win_amd64.whl
Size 404.8 kB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
ea82984378efebdda5d1edf332bc263a8c60ac311c5bc09ebb7ba0fb2119404a
BLAKE2b-256 checksum
How to use checksums
b3fa5feed27bcc6c25df080235ce09846708a51da85f85fba8c7a0a94f908eaa
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.3.1-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL faster_or_curvature-1.3.1-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 513.4 kB
Tags CPython 3.10 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
aa63e56a93d1b7bc96e2f40eff7ee65e965bed18afe21da4c1288e2b0031de25
BLAKE2b-256 checksum
How to use checksums
86ed4c88b62a8e70655edd0ed84ced2434356767259b02a9e349e9bce861a4ae
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.3.1-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

Download URL faster_or_curvature-1.3.1-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 494.7 kB
Tags CPython 3.10 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
2030a6d62ce9ed58bfaf8a5fc9d2b6aa5009c486cc86ececc6bc04d8aa900151
BLAKE2b-256 checksum
How to use checksums
d9a09b2b649f47210122efc4bfdbdc2c50f20aaea595e41957703b84348fa0a7
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.3.1-cp310-abi3-macosx_10_12_universal2.macosx_10_12_x86_64.macosx_11_0_arm64.whl

Download URL faster_or_curvature-1.3.1-cp310-abi3-macosx_10_12_universal2.macosx_10_12_x86_64.macosx_11_0_arm64.whl
Size 883.0 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
3913c7e9067085395240e95d087f6dec90dc742793b6f4163d754af61272795d
BLAKE2b-256 checksum
How to use checksums
df7ef18876290b4a96d40464097553167b077bcd9d1c7bbfab56ecebf4e821e6
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.3.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.3.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 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