Fast_dijkstra
Fast directed Dijkstra written in C++ with parallelization build in
Function definition
Parameters
----------
indptr : List[int]
indices : List[int]
weights : Sequence[float]
sources : List[int]
cutoff: OPTIONAL float (default = np.inf)
num_threads: OPTIONAL int (default = -1)
-1: maximum allowed threads
Returns
-------
distances : numpy.ndarray
Array of shape (num_sources, num_nodes) with shortest distances
predecessors : numpy.ndarray
Array of shape (num_sources, num_nodes) with predecessor indices
usage
- The graph is passed as a csr_matrix just like scipy. you can reuse scipy to create the graph from edges.
- edges must be integers. starting at 0
- Graph is directed
from scipy.sparse import csr_matrix
from fast_dijkstra import dijkstra, dijkstra_with_targets, dijkstra_on_multi_targets
edges = [(0, 1), (0, 2), (1, 2), (1, 3), (2, 3)]
weights = [1.0, 4.0, 2.0, 5.0, 1.0]
sources = [0, 1]
row = [e[0] for e in edges]
col = [e[1] for e in edges]
nodelist = sorted({e[0] for e in edges}.union({e[1] for e in edges}))
nlen = len(nodelist)
sparse = csr_matrix((weights, (row, col)), shape=(nlen, nlen))
indptr = sparse.indptr # [0, 2, 4, 5, 5]
indices = sparse.indices # [1, 2, 2, 3, 3]
# basic usage
distances, predecessor = dijkstra(indptr=indptr, indices=indices, weights=weights, sources=sources)
distances # [
# [ 0., 1., 3., 4.],
# [inf, 0., 2., 3.]
# ]
predecessor # [
# [-9999, 0, 1, 2],
# [-9999, -9999, 1, 2]
# ]
# with limits, and threads
distances, predecessor = dijkstra(
indptr=indptr, indices=indices, weights=weights, sources=sources, cutoff=10, num_threads=2
)
# with targets (return smaller predecessor/distances)
distances, predecessor = dijkstra_with_targets(
indptr=indptr, indices=indices, weights=weights, sources=sources, targets=[3]
)
# with limits, and threads
distances, predecessor = dijkstra_with_targets(
indptr=indptr, indices=indices, weights=weights, sources=sources, targets=[3]
)
# with target per source.
targets = [(0, 3), (1, 2), (1, 3)]
row = [e[0] for e in targets]
col = [e[1] for e in targets]
target_mat = csr_matrix(([1, 1, 1], (row, col)), shape=(nlen, nlen))
distances, predecessor = dijkstra_on_multi_targets(
indptr=indptr,
indices=indices,
weights=weights,
sources=sources,
target_indptr=target_mat.indptr,
target_indices=target_mat.indices,
)
to deploy
- change the version number in pyproject.toml under [project]
[project]
name = "fast_dijkstra"
version = "1.0.2"
- the poetry config is only used for local dev. to ignore.
- create a new tag starting with "v"
git tag -a 'v1.0.2' -m 'description'
git push origin v1.0.2
Github action will build wheels for windows and Linux.
- when Done, upload to Pypi
./upload v1.0.2
local development build
poetry run python setup.py bdist_wheel
or
poetry run python -m build --wheel
Metadata
Release files for fast-dijkstra 4.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distributions (wheels)
| File | Actions Reset | |||
|---|---|---|---|---|
| fast_dijkstra-4.1.0-cp312-cp312-win_amd64.whl | CPython 3.12 | CPython 3.12 | Windows x86-64 | Details for fast_dijkstra-4.1.0-cp312-cp312-win_amd64.whl |
| fast_dijkstra-4.1.0-cp312-cp312-win32.whl | CPython 3.12 | CPython 3.12 | Windows x86-32 | Details for fast_dijkstra-4.1.0-cp312-cp312-win32.whl |
| fast_dijkstra-4.1.0-cp312-cp312-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl | CPython 3.12 | CPython 3.12 | Linux glibc 2.28+ x86-64, Linux glibc 2.26+ x86-64 | Details for fast_dijkstra-4.1.0-cp312-cp312-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl |
| fast_dijkstra-4.1.0-cp312-cp312-macosx_26_0_arm64.whl | CPython 3.12 | CPython 3.12 | macOS 26.0+ ARM64 | Details for fast_dijkstra-4.1.0-cp312-cp312-macosx_26_0_arm64.whl |
Total release size: 1.8 MB
Release files / fast_dijkstra-4.1.0-cp312-cp312-win_amd64.whl
| Download URL | fast_dijkstra-4.1.0-cp312-cp312-win_amd64.whl |
|---|---|
| Size | 386.3 kB |
| Tags | CPython 3.12 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
6e5966b8a691cdb30bc847118f70d015a2952711cbc0fffa094ff10e278d2000
|
|
BLAKE2b-256 checksum How to use checksums |
2246f4e4d45ca86c44f3e7b2694503cfac49fa36d392ac8145a73a8f6ae2d414
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.12
|
Release files / fast_dijkstra-4.1.0-cp312-cp312-win32.whl
| Download URL | fast_dijkstra-4.1.0-cp312-cp312-win32.whl |
|---|---|
| Size | 366.3 kB |
| Tags | CPython 3.12 Windows x86-32 |
|
SHA-256 checksum How to use checksums |
392ce48ce3ad1978da2f3850bd2f6656efdbab4d851e3778ff7bddbc5fbf99b7
|
|
BLAKE2b-256 checksum How to use checksums |
b60873b8c718950280374c2352d83fba2027063b7555d0bf85cc570e74e09c01
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.12
|
Release files / fast_dijkstra-4.1.0-cp312-cp312-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl
| Download URL | fast_dijkstra-4.1.0-cp312-cp312-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 703.0 kB |
| Tags | CPython 3.12 Linux glibc 2.26+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
e78c56a33a45a56365d4e2bc1f3812463876a0c8f6382d4ed3f24583ed0989b9
|
|
BLAKE2b-256 checksum How to use checksums |
24c0af547530f28988e1c601836b296be2ff74549d54ed39d9774a4a4777316b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.12
|
Release files / fast_dijkstra-4.1.0-cp312-cp312-macosx_26_0_arm64.whl
| Download URL | fast_dijkstra-4.1.0-cp312-cp312-macosx_26_0_arm64.whl |
|---|---|
| Size | 344.4 kB |
| Tags | CPython 3.12 macOS 26.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
dfb98f6a7434f2b9bfff3c0f9be5768f3b8c0b1b2ba975d16aca95c7a4846642
|
|
BLAKE2b-256 checksum How to use checksums |
37edd565e225540e53c66d81cdf5e24ab7fbc18bd4d071383a61a7f23411d9cf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.12
|
Security for fast-dijkstra 4.1.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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
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.