dijkstras
v0.0.3
Published
Efficient implementation of Dijkstra's algorithm, with TypeScript support. This package is designed to be usable in both Node.js and browsers.
Downloads
4
Maintainers
Readme
Dijkstras
Dijkstras is a simple and efficient npm package that implements Dijkstra's algorithm for finding the shortest path in a weighted graph. This package supports TypeScript, ES6 , CJS, and it is designed to be usable in both Node.js and browsers.
Installation
To start using Dijkstras in your Node.js project, follow these steps:
Ensure that you have Node.js installed on your system. You can download it from https://nodejs.org.
Open your terminal or command prompt.
Navigate to your project directory.
Run the following command to install Dijkstras via npm:
npm install dijkstras
Wait for the installation process to complete.
Congratulations! You've successfully installed Dijkstras for your Node.js project.
Getting Started
To quickly get started with Dijkstras, follow these steps:
Import the Dijkstras module in your Node.js script:
import dijkstras from "dijkstras";
or :
const dijkstras = require("dijkstras");
Create a graph and use the provided methods to find the shortest path:
const graph = {
a: { b: 10, d: 1 },
b: { a: 1, c: 1, e: 1 },
c: { b: 1, f: 1 },
d: { a: 1, e: 1, g: 1 },
e: { b: 1, d: 1, f: 1, h: 1 },
f: { c: 1, e: 1, i: 1 },
g: { d: 1, h: 1 },
h: { e: 1, g: 1, i: 1 },
i: { f: 1, h: 1 },
};
const shortestPath = dijkstras.find_path(graph, "a", "i");
console.log("Shortest path:", shortestPath);
Contributing
We welcome contributions from the community to enhance Dijkstras. If you have ideas, bug reports, or feature requests, please open an issue on our GitHub repository at https://github.com/useCallback/dijkstras.
If you'd like to contribute code to the package, please follow these steps:
Fork the repository on GitHub.
Create a new branch for your feature or bug fix.
Make your changes and include appropriate tests.
Ensure that all tests pass by running the test suite.
Commit your changes and push the branch to your fork.
Open a pull request on the main repository, providing a detailed description of your changes.
License
Dijkstras is open source software released under the MIT License. You are free to use, modify, and distribute Dijkstras in accordance with the terms of the license.
Support
If you encounter any issues while using Dijkstras or have any questions, please contact me at [email protected]. We're here to help you!
Start finding the shortest paths with Dijkstras!