dijkstrajs is a lightweight, zero-dependency JavaScript library that provides a straightforward implementation of Dijkstra's single-source shortest-paths algorithm. Currently at version 1.0.3, the package was last published over three years ago, indicating a mature and stable codebase rather than active feature development. It is designed for use in Node.js environments and offers a simple API for finding the shortest path between two nodes in a weighted graph. While other Dijkstra implementations might offer performance optimizations like priority queues, dijkstrajs prioritizes simplicity and ease of integration for basic graph traversal needs. Developers should note its inherent limitation of not supporting negative edge weights, which is a fundamental constraint of Dijkstra's algorithm itself.
npm install dijkstrajsVerified import paths — ran on the pinned version, not inferred.
This example demonstrates how to define a weighted graph using an adjacency list and then use `findPath` to calculate the shortest path between specified start and end nodes.
Ensure all edge weights in your graph are non-negative, or use an alternative algorithm for graphs with negative weights.
For performance-critical applications with large graphs, benchmark this library against alternatives that explicitly mention priority queue optimizations.
Refer to the quickstart example for the precise graph object structure required by `dijkstrajs`.
Consider testing thoroughly with newer Node.js runtimes. For projects requiring active maintenance or advanced features, explore more recently updated graph libraries.
Use a named import for ESM: `import { findPath } from 'dijkstrajs'`. For CommonJS, ensure proper destructuring: `const { findPath } = require('dijkstrajs')`.Verify the `require` statement accurately destructures `findPath`: `const { findPath } = require('dijkstrajs')`. Ensure the package is correctly installed.Validate that the source and target nodes exist in the graph and that there is a connected path between them. Handle the `null` return explicitly in your application logic.
No dependency data recorded yet.