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.0-cp312-cp312-win_amd64.whl (69.7 kB view details)

Uploaded CPython 3.12Windows x86-64

fast_dijkstra-2.1.0-cp312-cp312-win32.whl (64.0 kB view details)

Uploaded CPython 3.12Windows x86

fast_dijkstra-2.1.0-cp312-cp312-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl (680.6 kB view details)

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

fast_dijkstra-2.1.0-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.0-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for fast_dijkstra-2.1.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 dd22b00f6666034d5f053525a6287bb340eab17f526031ca03158ee854bdf66e
MD5 bf868d644bd462138d8d481c3f36d907
BLAKE2b-256 9b895a9c45d837ad315d4ea879802d4c2e4efff21e713738d482babce3f7a9de

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fast_dijkstra-2.1.0-cp312-cp312-win32.whl
  • Upload date:
  • Size: 64.0 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.0-cp312-cp312-win32.whl
Algorithm Hash digest
SHA256 0e6269f80d11d403fada2b583b5b4edb6b6db15051f7a3e6faf4c5a3aad9d47c
MD5 c44d4a3646da94a0c15f1a98c15583d5
BLAKE2b-256 3af9ad77845a2142326d4dc3c620cb5b89568a515fbf09987eacd7382b2eaaa8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for fast_dijkstra-2.1.0-cp312-cp312-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 1e73178b30ff7d1ff7d078f064f6c89c74fe91921119f0d0cafd5230e10a6bce
MD5 fef1c2ad3661d5e9524e13e42583af8d
BLAKE2b-256 abb7ba31fba803cf543b6bec4645e0dc1061853b1f56a4fb235c5a618e7215da

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for fast_dijkstra-2.1.0-cp312-cp312-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 acdfce46bd00e2b83cfa899535c2feddb85bf6027900fac8aa894fa099c31d43
MD5 75b9a65e9f861eaeddd4b0de623004dd
BLAKE2b-256 6d1868ddc09c98ca173cc4c150f23c11b71aeb7abea1e5430973db9c72ce7a46

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