-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update readme + add github workflows
- Loading branch information
1 parent
55807eb
commit 3447283
Showing
14 changed files
with
153 additions
and
2,118 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
name: CI | ||
|
||
on: | ||
push: | ||
branches: | ||
- "**" | ||
pull_request: | ||
branches: | ||
- "**" | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
matrix: | ||
node-version: [14.x, 16.x, 18.x, 20.x] | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Use Node.js ${{ matrix.node-version }} | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
- run: npm install | ||
- run: npm test | ||
- run: npm run build --if-present |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
name: Publish Package to npmjs | ||
on: | ||
release: | ||
types: [published] | ||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: '16.x' | ||
registry-url: 'https://registry.npmjs.org' | ||
- run: npm install | ||
- run: npm test | ||
- run: npm run build --if-present | ||
- run: npm publish | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
node_modules | ||
node_modules/ | ||
dist/ | ||
.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
src/ | ||
scripts/ | ||
tsconfig.json | ||
.github | ||
.env |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,85 @@ | ||
# dijkstrajs.js | ||
# Dijkstras | ||
|
||
dijkstrajs is a simple JavaScript implementation of Dijkstra's single-source shortest-paths algorithm. | ||
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. | ||
|
||
The code was originally written by Wyatt Baldwin and turned into a node module by Thomas Cort. | ||
## Installation | ||
|
||
## Requirements | ||
To start using Dijkstras in your Node.js project, follow these steps: | ||
|
||
* [nodejs](http://nodejs.org/) | ||
1. Ensure that you have Node.js installed on your system. You can download it from [https://nodejs.org](https://nodejs.org). | ||
|
||
## Installation | ||
2. Open your terminal or command prompt. | ||
|
||
3. Navigate to your project directory. | ||
|
||
4. Run the following command to install Dijkstras via npm: | ||
|
||
```shell | ||
npm install dijkstras | ||
``` | ||
|
||
5. Wait for the installation process to complete. | ||
|
||
6. Congratulations! You've successfully installed Dijkstras for your Node.js project. | ||
## Getting Started | ||
To quickly get started with Dijkstras, follow these steps: | ||
1. Import the Dijkstras module in your Node.js script: | ||
```typescript | ||
import dijkstras from "dijkstras"; | ||
``` | ||
or : | ||
```javascript | ||
const dijkstras = require("dijkstras"); | ||
``` | ||
2. Create a graph and use the provided methods to find the shortest path: | ||
```typescript | ||
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](https://github.com/useCallback/dijkstras). | ||
If you'd like to contribute code to the package, please follow these steps: | ||
|
||
1. Fork the repository on GitHub. | ||
|
||
2. Create a new branch for your feature or bug fix. | ||
|
||
3. Make your changes and include appropriate tests. | ||
|
||
4. Ensure that all tests pass by running the test suite. | ||
|
||
5. Commit your changes and push the branch to your fork. | ||
|
||
6. Open a pull request on the main repository, providing a detailed description of your changes. | ||
|
||
## License | ||
|
||
npm install dijkstrajs | ||
Dijkstras is open source software released under the [MIT License](https://opensource.org/licenses/MIT). You are free to use, modify, and distribute Dijkstras in accordance with the terms of the license. | ||
|
||
## Examples | ||
## Support | ||
|
||
See `test/dijkstra.test.js` in the sources for some example code. | ||
If you encounter any issues while using Dijkstras or have any questions, please contact me at [[email protected]](mailto:[email protected]). We're here to help you! | ||
Start finding the shortest paths with Dijkstras! |
Oops, something went wrong.