Skip to main content

Fast Dijkstra

Project description

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

  1. 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.
  1. 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.

  1. 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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

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

fast_dijkstra-2.1.1-cp312-cp312-win_amd64.whl (69.7 kB view details)

Uploaded CPython 3.12Windows x86-64

fast_dijkstra-2.1.1-cp312-cp312-win32.whl (63.9 kB view details)

Uploaded CPython 3.12Windows x86

fast_dijkstra-2.1.1-cp312-cp312-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl (680.7 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.26+ x86-64manylinux: glibc 2.28+ x86-64

fast_dijkstra-2.1.1-cp312-cp312-macosx_15_0_arm64.whl (318.4 kB view details)

Uploaded CPython 3.12macOS 15.0+ ARM64

File details

Details for the file fast_dijkstra-2.1.1-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for fast_dijkstra-2.1.1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 c39aad4b61995f1dec3bfb6db89be0198456ad463163117f497ced6a7ffa024c
MD5 26f67f28cf9bf6f5ec7d3a61cfe9c3b0
BLAKE2b-256 f31a18ebd2bf287b484655403ba55c6bf1d758f9dfa53c183d2ec12c7c80b252

See more details on using hashes here.

File details

Details for the file fast_dijkstra-2.1.1-cp312-cp312-win32.whl.

File metadata

  • Download URL: fast_dijkstra-2.1.1-cp312-cp312-win32.whl
  • Upload date:
  • Size: 63.9 kB
  • Tags: CPython 3.12, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.8.6

File hashes

Hashes for fast_dijkstra-2.1.1-cp312-cp312-win32.whl
Algorithm Hash digest
SHA256 889f003fb4b12dd6c438a172d28e0913d477e626d98053b80af05634b146db42
MD5 81aaa12230cd145d26c4ba8380a4d4b3
BLAKE2b-256 ac21352bd893de0a6e51423384a33c88590c1602c8e2afdacae42f8be31164ee

See more details on using hashes here.

File details

Details for the file fast_dijkstra-2.1.1-cp312-cp312-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for fast_dijkstra-2.1.1-cp312-cp312-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 6030e232f248daae8eee160176edc58454fd70ad9412a6966114348437fc15e9
MD5 c7f86e3a48e37ce462c41833bc1da142
BLAKE2b-256 8555ef2ea69f3d43a829f49991248fb91b7df6fb29bd95ad2aa2a43691ebb15f

See more details on using hashes here.

File details

Details for the file fast_dijkstra-2.1.1-cp312-cp312-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for fast_dijkstra-2.1.1-cp312-cp312-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 5f24b815eee59a299cb052fcf8470802100e3255917c4ea6d886d7393d41d3ba
MD5 8d7bf493ad4749d6587fd0ee314c56a5
BLAKE2b-256 1fc9eeaf38ae37f5128e6e83488a18491319c3b24f035c848be680e16d6d37a0

See more details on using hashes here.

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