Skip to main content

Graph optimal transport on sparse reversible graphs

Project description

graphot

graphot solves dynamic optimal transport on sparse reversible graphs.

Use it when you want:

  • a transport path between two endpoint distributions on a graph,
  • node densities over time,
  • edge fluxes over time,
  • a solver that runs from Python and returns NumPy arrays.

Install

Install from PyPI:

pip install graphot

If you want to run the plotting examples:

pip install "graphot[examples]"

If you are working from a local checkout instead, run pip install . or pip install ".[examples]" from the repository root.

These docs use the public import path graphot:

from graphot import solve_ot

Quick Start

import numpy as np

from graphot import (
    GraphSpec,
    LogMeanOps,
    OTConfig,
    OTProblem,
    TimeDiscretization,
    solve_ot,
)

graph = GraphSpec.from_undirected_weights(
    num_nodes=2,
    edge_u=[0],
    edge_v=[1],
    weight=[1.0],
)

mass_a = np.array([1.0, 0.0], dtype=np.float64)
mass_b = np.array([0.0, 1.0], dtype=np.float64)

rho_a = mass_a / graph.pi
rho_b = mass_b / graph.pi

problem = OTProblem(
    graph=graph,
    time=TimeDiscretization(num_steps=64),
    rho_a=rho_a,
    rho_b=rho_b,
    mean_ops=LogMeanOps(),
)

solution = solve_ot(problem, OTConfig())

print("distance:", float(solution.distance))
print("converged:", solution.converged)
print("iterations:", solution.iterations_used)

Three Things To Remember

  • graphot expects endpoint densities with respect to graph.pi, not raw masses.
  • Convert ordinary masses with rho = mass / graph.pi.
  • Check solution.converged on harder problems before treating the result as final.

What You Get Back

The most useful outputs are:

  • solution.distance
  • solution.state.rho
  • solution.state.m
  • solution.diagnostics

Start Here

Examples

The repository includes ready-to-run scripts for:

  • two-node transport,
  • cycle transport,
  • line transport,
  • directed reversible transport,
  • large-grid transport.

See examples/README.md for the example index.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

graphot-0.0.2.tar.gz (131.3 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

graphot-0.0.2-cp313-cp313-win_amd64.whl (112.7 kB view details)

Uploaded CPython 3.13Windows x86-64

graphot-0.0.2-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (121.5 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.24+ x86-64manylinux: glibc 2.28+ x86-64

graphot-0.0.2-cp313-cp313-macosx_11_0_arm64.whl (98.4 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

graphot-0.0.2-cp312-cp312-win_amd64.whl (112.7 kB view details)

Uploaded CPython 3.12Windows x86-64

graphot-0.0.2-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (121.7 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.24+ x86-64manylinux: glibc 2.28+ x86-64

graphot-0.0.2-cp312-cp312-macosx_11_0_arm64.whl (98.3 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

graphot-0.0.2-cp311-cp311-win_amd64.whl (113.8 kB view details)

Uploaded CPython 3.11Windows x86-64

graphot-0.0.2-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (121.8 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.24+ x86-64manylinux: glibc 2.28+ x86-64

graphot-0.0.2-cp311-cp311-macosx_11_0_arm64.whl (99.0 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

File details

Details for the file graphot-0.0.2.tar.gz.

File metadata

  • Download URL: graphot-0.0.2.tar.gz
  • Upload date:
  • Size: 131.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for graphot-0.0.2.tar.gz
Algorithm Hash digest
SHA256 74a95fd17264f363cfbcf0b8b1f14a9c94729e1fb7fdfd6b825d2d7c3d44de19
MD5 2d09ea044497e0349f3803d0b0c876f0
BLAKE2b-256 cf5dfe3a9efce72d90681c0025619be5c199c5acc10612a007e440d2a8260721

See more details on using hashes here.

Provenance

The following attestation bundles were made for graphot-0.0.2.tar.gz:

Publisher: publish.yml on LvDAO/Graph-Optimal-Transport

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file graphot-0.0.2-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: graphot-0.0.2-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 112.7 kB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for graphot-0.0.2-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 29679284aa7aa9f3b7113bf3e63d0e37fe260c066689f6f2b0cdb32712bd8ffa
MD5 83f64bfa4ede6c7e5152841ce7c2177f
BLAKE2b-256 783bbceb51e043378d2e3d35c75ee2d2f10ab6a5d01d690f59f65d504077ffed

See more details on using hashes here.

Provenance

The following attestation bundles were made for graphot-0.0.2-cp313-cp313-win_amd64.whl:

Publisher: publish.yml on LvDAO/Graph-Optimal-Transport

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file graphot-0.0.2-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for graphot-0.0.2-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 2fb85ffd9b70a8d7e1fd2b41fe212e1d42908d008bced13e50092dab8372f989
MD5 c3868f30561906afd50fb1437db9490e
BLAKE2b-256 73e60f0ddc8fd2589ab15177768fa6fd803a277901b0260c69ccf1e85533f927

See more details on using hashes here.

Provenance

The following attestation bundles were made for graphot-0.0.2-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl:

Publisher: publish.yml on LvDAO/Graph-Optimal-Transport

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file graphot-0.0.2-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for graphot-0.0.2-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b0cc13b4b853114f278bd911d75f79d9f1df1d5873b098ae8451cc22c25bdfcb
MD5 4e53c54da984d2a44765c488a2dd6f37
BLAKE2b-256 51c258aa34387ff76a9d75c72ed13f4a0405cd3d419fe39df268b6bc89e9a231

See more details on using hashes here.

Provenance

The following attestation bundles were made for graphot-0.0.2-cp313-cp313-macosx_11_0_arm64.whl:

Publisher: publish.yml on LvDAO/Graph-Optimal-Transport

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file graphot-0.0.2-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: graphot-0.0.2-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 112.7 kB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for graphot-0.0.2-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 555a45a6f9e67725e95fd577e2dcaf780d596d07d020caf6c45138be13320699
MD5 d0e7a00f52b4aa478f48f1a6caf947a8
BLAKE2b-256 149c60785203679bb0ba30cbf658ae8500d20c33d2d7b226a487d14d241757ed

See more details on using hashes here.

Provenance

The following attestation bundles were made for graphot-0.0.2-cp312-cp312-win_amd64.whl:

Publisher: publish.yml on LvDAO/Graph-Optimal-Transport

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file graphot-0.0.2-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for graphot-0.0.2-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 b55a26bb66c7a70101bb5ba0497399b5b2bb5cf852ff733866df39431e1d33f0
MD5 bb3560d97dc5b27f6d091c3826ba3ff3
BLAKE2b-256 865e84e6864df7e0d7945b5d3b701345e523d7262853f4ef10fa320846778fe7

See more details on using hashes here.

Provenance

The following attestation bundles were made for graphot-0.0.2-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl:

Publisher: publish.yml on LvDAO/Graph-Optimal-Transport

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file graphot-0.0.2-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for graphot-0.0.2-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4b5e3eb48fdc5bbb7f4805514f1ad8265013eb1cebfbb84f7c044a8618093556
MD5 99211de796888abd33567d68bf1727fe
BLAKE2b-256 b0859141cac4171ea3cf7e028c1cb965bcce77036eee18e33b60c155846cb5af

See more details on using hashes here.

Provenance

The following attestation bundles were made for graphot-0.0.2-cp312-cp312-macosx_11_0_arm64.whl:

Publisher: publish.yml on LvDAO/Graph-Optimal-Transport

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file graphot-0.0.2-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: graphot-0.0.2-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 113.8 kB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for graphot-0.0.2-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 a5f237d1dfb1f5fb8a8c1d2f08309d5f081b666ff02816a4827083e25b73a72f
MD5 ec7ef5b86fff1d746db85d2b5d5170fe
BLAKE2b-256 2846eaf07d8035c8e1e3d6c082bbf25542c54dca3337465f3aaa30994ac74d36

See more details on using hashes here.

Provenance

The following attestation bundles were made for graphot-0.0.2-cp311-cp311-win_amd64.whl:

Publisher: publish.yml on LvDAO/Graph-Optimal-Transport

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file graphot-0.0.2-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for graphot-0.0.2-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 a282db6a3c89f1afaf57130ccd6ac9777486c36cb2359d40e14c8c45dbc0f963
MD5 f9b63181a45ae886dfed091d8c524703
BLAKE2b-256 514316a29caa8997ebc5a29a376bde2668cb3cd95625c1edd17b94e12c4b48b9

See more details on using hashes here.

Provenance

The following attestation bundles were made for graphot-0.0.2-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl:

Publisher: publish.yml on LvDAO/Graph-Optimal-Transport

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file graphot-0.0.2-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for graphot-0.0.2-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d54bbc03c62c187f103b9153e1d255c63f558077e886b179cdc579db3fa02ae4
MD5 43e14923295ba0d50ba183009363accb
BLAKE2b-256 bbbce528d743674594eaa970e9037924c95d2ae45e4b59824f0a96072cf9fa93

See more details on using hashes here.

Provenance

The following attestation bundles were made for graphot-0.0.2-cp311-cp311-macosx_11_0_arm64.whl:

Publisher: publish.yml on LvDAO/Graph-Optimal-Transport

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page