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.0.tar.gz (173.5 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.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (355.6 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

pyroutingkit-0.2.0-cp313-cp313-macosx_11_0_arm64.whl (213.0 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

pyroutingkit-0.2.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (355.6 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

pyroutingkit-0.2.0-cp312-cp312-macosx_11_0_arm64.whl (213.0 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

pyroutingkit-0.2.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (355.2 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

pyroutingkit-0.2.0-cp311-cp311-macosx_11_0_arm64.whl (211.2 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

pyroutingkit-0.2.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (354.4 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

pyroutingkit-0.2.0-cp310-cp310-macosx_11_0_arm64.whl (210.1 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

File details

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

File metadata

  • Download URL: pyroutingkit-0.2.0.tar.gz
  • Upload date:
  • Size: 173.5 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.0.tar.gz
Algorithm Hash digest
SHA256 2fbdc834c237259e01ea7fa807bc8cadbe973433b8c31c501bafef5ac6f54cb8
MD5 d8737214193144c803cab4ee5a2e8e4c
BLAKE2b-256 255594a6045eb004a728c4b435ed50248ddb7af5eeaaf6d7786de409b30c7395

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyroutingkit-0.2.0.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.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyroutingkit-0.2.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 fc6febd3f7689a5367d6da767038ed2c61c574a7bf617bbabb8fd1f086410664
MD5 d141f759bc862ccb3c329c4740cafce2
BLAKE2b-256 ae0413569c2d1bb8ca113823026946bc33067f322286b2660f8e858cee95a156

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyroutingkit-0.2.0-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.0-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyroutingkit-0.2.0-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 05779fa196d3ed54390dd09439394d41fc1f0a7990b2e507263733220838cf14
MD5 f6b822c5a0f9cee2aeb11c733f242242
BLAKE2b-256 eb24b3e6958f7d59f70d3ce34034e6fd6121f20a66c0f24ec64cfeab61efee27

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyroutingkit-0.2.0-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.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyroutingkit-0.2.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 91b2b7ac51a87bd35df18a1e43147c5c0ec2dae1247bf5681c50f0c6e8ec8135
MD5 a3b98f1eac89a5237504391849fd66d8
BLAKE2b-256 06e5fbf1502166e63632e4339f3694a4f104038f49ed29dd9becece00b561d08

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyroutingkit-0.2.0-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.0-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyroutingkit-0.2.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 fb15afb612d0a7e0e4f05423bb5aa1f237897d97c8f63167e36fa9d52df69626
MD5 e9666008d913a9ba9d817d7b93788fcd
BLAKE2b-256 50b04fe72b8020cc892c07d9344479673315532978c3f64885d7b99c122ddd64

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyroutingkit-0.2.0-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.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyroutingkit-0.2.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 f54c8bdb31996e7f04778b63964b2bae572c9aa44b0df7f263a0b1536d59f47b
MD5 021ec40755b959f1b3feb52d32efbc92
BLAKE2b-256 1d20e4110a01a255fa49aefd45583430d39166fce1be69b0e025464751c6603b

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyroutingkit-0.2.0-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.0-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyroutingkit-0.2.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4473b6f580ee0be6421f3923bc5aabb378797be5c2499eb4155d00559c95efb1
MD5 2cf1794cc7edf186f880b852a1525e40
BLAKE2b-256 2e9ed3987b882cce0e7f5fc893db72bbf2d3362c39b0dea2754cd43fa1662945

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyroutingkit-0.2.0-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.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyroutingkit-0.2.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d703c799b18156107a970f8987ec38ad6d3521b03f91ad440b4316413adfcca3
MD5 048ea7c44740271825d997781c393e45
BLAKE2b-256 1eb429fbce427ad9e8ab28ba5f531d345afadebf123d9b5fed257a8bf5859ce5

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyroutingkit-0.2.0-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.0-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyroutingkit-0.2.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7f72467de75732d39ad5bde869bb119ee18e175fe1cd9235fa972b0f712685d1
MD5 d69e58fb52bc0758dd96096b1acb69c9
BLAKE2b-256 178c4616d850af72e450d31dfa84e401ab1411f21ed2fa86b2f8c5a6bad82b41

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyroutingkit-0.2.0-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