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
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]
distances, predecessor = dijkstra(indptr, indices, weights, sources)
distances # [
# [ 0., 1., 3., 4.],
# [inf, 0., 2., 3.]
# ]
predecessor # [
# [-9999, 0, 1, 2],
# [-9999, -9999, 1, 2]
# ]
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 3.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distributions (wheels)
| File | Reset | |||
|---|---|---|---|---|
| fast_dijkstra-3.0.0-cp312-cp312-win_amd64.whl | CPython 3.12 | CPython 3.12 | Windows x86-64 | Details |
| fast_dijkstra-3.0.0-cp312-cp312-win32.whl | CPython 3.12 | CPython 3.12 | Windows x86-32 | Details |
| fast_dijkstra-3.0.0-cp312-cp312-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl | CPython 3.12 | CPython 3.12 | Linux glibc 2.26+ x86-64, Linux glibc 2.28+ x86-64 | Details |
| fast_dijkstra-3.0.0-cp312-cp312-macosx_26_0_arm64.whl | CPython 3.12 | CPython 3.12 | macOS 26.0+ ARM64 | Details |
Total release size: 1.8 MB
Release files / fast_dijkstra-3.0.0-cp312-cp312-win_amd64.whl
| Download URL | fast_dijkstra-3.0.0-cp312-cp312-win_amd64.whl |
|---|---|
| Size | 380.5 kB |
| Tags | CPython 3.12 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
ab86b770cb47e9d585c7c790970aea897974310a654be45e102adc3fae833f80
|
|
BLAKE2b-256 checksum How to use checksums |
651a03f5aa7e08447be8af691ef01a5e8e3800a3ebf2483e1aaeb55fe37c1867
|
| 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-3.0.0-cp312-cp312-win32.whl
| Download URL | fast_dijkstra-3.0.0-cp312-cp312-win32.whl |
|---|---|
| Size | 360.7 kB |
| Tags | CPython 3.12 Windows x86-32 |
|
SHA-256 checksum How to use checksums |
80108d79eebafc255e3602529b359a723104c6bdc4ce76f581a381d851d9a854
|
|
BLAKE2b-256 checksum How to use checksums |
ae504cc184e169b4f159815ca78d43c0f397bee3730b47db2484134cf3883181
|
| 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-3.0.0-cp312-cp312-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl
| Download URL | fast_dijkstra-3.0.0-cp312-cp312-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 697.8 kB |
| Tags | CPython 3.12 Linux glibc 2.26+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
78fc78b5b9ece03941c60f01e9be7c32d7dbfe6da9128a04f615bd06b30f379f
|
|
BLAKE2b-256 checksum How to use checksums |
09dfea9273ab89480c32c94f61e278fe6d9a9a304fab1afce4ee571ee50210a7
|
| 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-3.0.0-cp312-cp312-macosx_26_0_arm64.whl
| Download URL | fast_dijkstra-3.0.0-cp312-cp312-macosx_26_0_arm64.whl |
|---|---|
| Size | 329.7 kB |
| Tags | CPython 3.12 macOS 26.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
7c46d01e1cae01aad692ea71b78feb339ce10ccf779e19efc31937d30091b567
|
|
BLAKE2b-256 checksum How to use checksums |
491c62292e8e53f9b42b8e1b851f10d1a8eebfa93730df5166616b6213e15f58
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.12
|