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.1.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.1.0-cp312-cp312-win_amd64.whl | CPython 3.12 | CPython 3.12 | Windows x86-64 | Details |
| fast_dijkstra-3.1.0-cp312-cp312-win32.whl | CPython 3.12 | CPython 3.12 | Windows x86-32 | Details |
| fast_dijkstra-3.1.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.1.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.1.0-cp312-cp312-win_amd64.whl
| Download URL | fast_dijkstra-3.1.0-cp312-cp312-win_amd64.whl |
|---|---|
| Size | 382.5 kB |
| Tags | CPython 3.12 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
f97c30a2202811a18a4c5113bfe149e29c5cf3e7f8de56f2e9d303e508571d6f
|
|
BLAKE2b-256 checksum How to use checksums |
a2fcb39a1e6a686e5b3a54cac51878fc7495aca4e92af39fad97ab7393e5b8e7
|
| 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.1.0-cp312-cp312-win32.whl
| Download URL | fast_dijkstra-3.1.0-cp312-cp312-win32.whl |
|---|---|
| Size | 362.7 kB |
| Tags | CPython 3.12 Windows x86-32 |
|
SHA-256 checksum How to use checksums |
1d18be9c171a6c83b68deadf2c9ea3d406c058f0e80b4938f237cc243eea66fb
|
|
BLAKE2b-256 checksum How to use checksums |
00e3b0960104e309684a397679c27b09cb74ceee0fdf05e05ac9dae6d5857a40
|
| 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.1.0-cp312-cp312-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl
| Download URL | fast_dijkstra-3.1.0-cp312-cp312-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 697.3 kB |
| Tags | CPython 3.12 Linux glibc 2.26+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
8322605a5aabc5c06cfade6ed546bd3e384e1e8691c4d18d500b8425a420fc14
|
|
BLAKE2b-256 checksum How to use checksums |
fc5b8601a8b0592cb93252b51cdd54f65d3634a6201883d73a90c9391784c1ce
|
| 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.1.0-cp312-cp312-macosx_26_0_arm64.whl
| Download URL | fast_dijkstra-3.1.0-cp312-cp312-macosx_26_0_arm64.whl |
|---|---|
| Size | 333.8 kB |
| Tags | CPython 3.12 macOS 26.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
465e511b31af210fc32c7e71e258453d13f64382b17843b546d2bedaf4cd3b3d
|
|
BLAKE2b-256 checksum How to use checksums |
d6005ae6b49bfe5b2c803e79a6f20b55fcf4bacf60390ca23493d102921f0e9a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.12
|