Registry / data / dijkstar

dijkstar

JSON →
library2.6.0pypypi✓ verified 85d ago

Dijkstar is an implementation of Dijkstra's single-source shortest paths algorithm and the A* algorithm for weighted multigraphs. Current version 2.6.0 (release frequency: occasional). It is simple to use and allows custom graph structures.

pip install dijkstar
INSTALL
IMPORT
SIG · DIJKSTAR
D
dijkstar
datapythonv2.6.0
Install
1.6s avg
Import
36ms
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v2.6.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.036s · 18MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.6s · import 0.036s · 18MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Graph
from dijkstar import Graph
Correct import for the Graph class.
find_path
from dijkstar import find_path
Correct import for the pathfinding function.

Create a weighted graph and find the shortest path between two nodes.

from dijkstar import Graph, find_path graph = Graph() graph.add_edge(1, 2, 100) graph.add_edge(2, 3, 200) path_info = find_path(graph, 1, 3) print('Shortest path:', path_info.nodes) print('Total cost:', path_info.total_cost)
Debug
Known issues
gotchaGraph is a multigraph; adding multiple edges between the same nodes with different costs is allowed and may lead to unexpected shortest paths if not careful.
fix
Ensure that duplicate edges with unintended costs are not added inadvertently.
affects: >=2.0.0
gotchaNode IDs must be hashable; using unhashable types (like lists) as nodes will raise an error.
fix
Use hashable node types such as integers, strings, or tuples.
affects: all
Errors
Common errors & fixes
AttributeError: module 'dijkstar' has no attribute 'Graph'
Importing incorrectly (e.g., import dijkstar then dijkstar.Graph) or having a different version where Graph is not top-level.
fix
Use: from dijkstar import Graph
KeyError: node not in graph
Attempting to find a path from or to a node that has not been added to the graph.
fix
Ensure all nodes in the path query are present in the graph.
Upgrade
Version history
2.6.0latest on PyPI · released Mar 30, 2021
Audit
Dependencies

No dependency data recorded yet.

Agent activity
5 hits · last 30 days
node
4
OpenAI (training)
1
Resources
dijkstar — pip install dijkstar · libregistry