Skip to main content

Python bindings for RoutingKit Customizable Contraction Hierarchies (CCH)

Project description

pyroutingkit

Python bindings for RoutingKit Customizable Contraction Hierarchies (CCH).

Provides microsecond-scale shortest-path queries on large road networks (millions of nodes). Pre-compiled wheels for Linux (manylinux) and macOS — no C++ toolchain needed at install time.

Install

pip install pyroutingkit

Usage

import numpy as np
from pyroutingkit import CCH, INF_WEIGHT

# Build topology (one-time, expensive — can be saved/loaded)
cch = CCH()
tail = np.array([0, 1, 2], dtype=np.uint32)
head = np.array([1, 2, 0], dtype=np.uint32)
lat = np.array([9.0, 9.5, 9.2], dtype=np.float32)
lon = np.array([38.7, 39.0, 38.5], dtype=np.float32)
cch.build_topology(tail, head, lat, lon, node_count=3)

# Customize with weights (fast, can be called multiple times)
weights = np.array([100, 150, 120], dtype=np.uint32)
cch.customize_weights(weights)

# Query (microseconds)
distance, path = cch.query(0, 2)
print(f"Distance: {distance}, Path: {path}")

# Many-to-many matrix
sources = np.array([0, 1], dtype=np.uint32)
targets = np.array([1, 2], dtype=np.uint32)
matrix = cch.distances_many_to_many(sources, targets)

# Save/load topology (skip expensive build on next run)
cch.save_topology("/tmp/cch_cache")
cch2 = CCH()
cch2.load_topology("/tmp/cch_cache")
cch2.customize_weights(weights)  # Must re-customize after load

API

CCH class

Method Description
build_topology(tail, head, lat, lon, node_count) Build CCH from graph arrays. Uses inertial flow for node ordering.
customize_weights(weights) Set edge weights (uint32). Can be called multiple times.
query(source, target) Point-to-point query. Returns (distance, path).
distances_many_to_many(sources, targets) NxM distance matrix.
save_topology(dir_path) Save topology to disk (binary format).
load_topology(dir_path) Load topology from disk (skips build).

Properties

Property Type Description
node_count int Number of nodes
arc_count int Number of directed edges
is_built bool Topology has been built or loaded
is_customized bool Weights have been set

Constants

Constant Description
INF_WEIGHT Sentinel value for unreachable pairs

Building from source

Requires CMake 3.20+ and a C++17 compiler.

git clone --recurse-submodules https://github.com/nullbutt/pyroutingkit
cd pyroutingkit
uv build

License

MIT. RoutingKit is also MIT-licensed.

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

pyroutingkit-0.2.1.tar.gz (174.1 kB view details)

Uploaded Source

Built Distributions

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

pyroutingkit-0.2.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (355.8 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

pyroutingkit-0.2.1-cp313-cp313-macosx_11_0_arm64.whl (213.2 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

pyroutingkit-0.2.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (355.8 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

pyroutingkit-0.2.1-cp312-cp312-macosx_11_0_arm64.whl (213.1 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

pyroutingkit-0.2.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (355.4 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

pyroutingkit-0.2.1-cp311-cp311-macosx_11_0_arm64.whl (211.3 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

pyroutingkit-0.2.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (354.5 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

pyroutingkit-0.2.1-cp310-cp310-macosx_11_0_arm64.whl (210.2 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

File details

Details for the file pyroutingkit-0.2.1.tar.gz.

File metadata

  • Download URL: pyroutingkit-0.2.1.tar.gz
  • Upload date:
  • Size: 174.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pyroutingkit-0.2.1.tar.gz
Algorithm Hash digest
SHA256 144fa582c824ea94075abc1fce5d2b2cecadfd87d83cf1b39b3ad28138ef79e4
MD5 9985f2ea2e03384541d5dd56d2cf5db7
BLAKE2b-256 e6156f27b9aa2b2f2ed9d3f40c71435a650375b40827d15cb3c67ad5777d1f34

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyroutingkit-0.2.1.tar.gz:

Publisher: publish.yml on nullbutt/pyroutingkit

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

File details

Details for the file pyroutingkit-0.2.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyroutingkit-0.2.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 4321d24392055a9263e2fc3df520398e0fa9b928fb31e63715c3089c81650939
MD5 0adea5127b727d4fdd31faa2496f3a5b
BLAKE2b-256 c4888144e55fff4db9c5b934feb066a0c644fa34a098dd0994590422ebba86e0

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyroutingkit-0.2.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: publish.yml on nullbutt/pyroutingkit

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

File details

Details for the file pyroutingkit-0.2.1-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyroutingkit-0.2.1-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0d083842f4b1b32b518360c801642967e9344bd30b86807fca6223740ba588cc
MD5 7b78692ff2bed33625b36f0b93f3aa99
BLAKE2b-256 bdcd9da728ac6baaadbae32fd59e8d6918fc617859e9df0f10e35e7ddabc3139

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyroutingkit-0.2.1-cp313-cp313-macosx_11_0_arm64.whl:

Publisher: publish.yml on nullbutt/pyroutingkit

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

File details

Details for the file pyroutingkit-0.2.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyroutingkit-0.2.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 4bc81f3e0772c0fbd17db77734b96d70028b7acbb18c773b8b9b92985f69dab4
MD5 770ebe5458400730f55cbcda1ea2ebb9
BLAKE2b-256 12e7f0db494ebab530b1b417e3f3c0f811e6e61026fddf35296cf18abb3723dc

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyroutingkit-0.2.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: publish.yml on nullbutt/pyroutingkit

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

File details

Details for the file pyroutingkit-0.2.1-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyroutingkit-0.2.1-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 203ce70baacc869f9e7eb3e7f5e69e50992473488d5c9d566704b0f85d97fb57
MD5 f94f39cfcb7c57d458276297a7951264
BLAKE2b-256 0c4de1203e87d247fee874b432610a2f1525834ca53aff40b505cc488b72ac4b

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyroutingkit-0.2.1-cp312-cp312-macosx_11_0_arm64.whl:

Publisher: publish.yml on nullbutt/pyroutingkit

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

File details

Details for the file pyroutingkit-0.2.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyroutingkit-0.2.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 26a2f3f8ab1af06b0976cd3f4ddb0fa48e00ffb5094ab74ba7e65ec7b661a3fb
MD5 c9da6c2508ab844b2fe184f98888bd4d
BLAKE2b-256 3b23387fa4975405fff63721c1773384f6cc23f169849b1af4284be01cf0b51e

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyroutingkit-0.2.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: publish.yml on nullbutt/pyroutingkit

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

File details

Details for the file pyroutingkit-0.2.1-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyroutingkit-0.2.1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e5af766b2cb6b777a6202f46965d8bfd9af4f7c058f0fac56c57df511f553f63
MD5 79523626a006eee68cc36c4504b276ca
BLAKE2b-256 68c1ecf85f640e758b324d613b500994804bce17751fb2be227bc0b06b7b6a51

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyroutingkit-0.2.1-cp311-cp311-macosx_11_0_arm64.whl:

Publisher: publish.yml on nullbutt/pyroutingkit

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

File details

Details for the file pyroutingkit-0.2.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyroutingkit-0.2.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 88fd8445d431681bb59205a8acf847cf0723662a994fe082b8172a1f6082e79a
MD5 5706be4a917c1cbdecb475487884b0ab
BLAKE2b-256 abde5bbf4f297b8bac2c759660f3a3f7600fe159bac293b89ca8e4c4ba702c65

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyroutingkit-0.2.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: publish.yml on nullbutt/pyroutingkit

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

File details

Details for the file pyroutingkit-0.2.1-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyroutingkit-0.2.1-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6cc783c7e9c155c7380a30555096c4c684e82c1082b2c1454fec1a709b87269a
MD5 f1e12ebe2b9650f5f13b552662e71485
BLAKE2b-256 e1166b0d77142022e173c4f41d825793ac8758dbcb250c13e4b7943b0f3d96c1

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyroutingkit-0.2.1-cp310-cp310-macosx_11_0_arm64.whl:

Publisher: publish.yml on nullbutt/pyroutingkit

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