{"id":43094021,"url":"https://github.com/albertorestifo/node-dijkstra","last_synced_at":"2026-01-31T16:30:06.429Z","repository":{"id":30271087,"uuid":"33822538","full_name":"albertorestifo/node-dijkstra","owner":"albertorestifo","description":"A NodeJS implementation of Dijkstra's algorithm","archived":false,"fork":false,"pushed_at":"2025-11-05T08:51:11.000Z","size":396,"stargazers_count":160,"open_issues_count":6,"forks_count":37,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-11-05T10:15:32.487Z","etag":null,"topics":["dijkstra","node-graph","nodejs"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/albertorestifo.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2015-04-12T15:38:04.000Z","updated_at":"2025-09-17T08:01:52.000Z","dependencies_parsed_at":"2025-09-17T09:32:06.941Z","dependency_job_id":null,"html_url":"https://github.com/albertorestifo/node-dijkstra","commit_stats":null,"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"purl":"pkg:github/albertorestifo/node-dijkstra","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/albertorestifo%2Fnode-dijkstra","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/albertorestifo%2Fnode-dijkstra/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/albertorestifo%2Fnode-dijkstra/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/albertorestifo%2Fnode-dijkstra/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/albertorestifo","download_url":"https://codeload.github.com/albertorestifo/node-dijkstra/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/albertorestifo%2Fnode-dijkstra/sbom","scorecard":{"id":178072,"data":{"date":"2025-08-11","repo":{"name":"github.com/albertorestifo/node-dijkstra","commit":"8ccf44bb9f82dce8dad4ce9a94f69c93398836d9"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.8,"checks":[{"name":"Maintained","score":5,"reason":"7 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 5","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Code-Review","score":2,"reason":"Found 4/18 approved changesets -- score normalized to 2","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/test.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Pinned-Dependencies","score":4,"reason":"dependency not pinned by hash detected -- score normalized to 4","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:19: update your workflow using https://app.stepsecurity.io/secureworkflow/albertorestifo/node-dijkstra/test.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:22: update your workflow using https://app.stepsecurity.io/secureworkflow/albertorestifo/node-dijkstra/test.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/test.yml:31: update your workflow using https://app.stepsecurity.io/secureworkflow/albertorestifo/node-dijkstra/test.yml/master?enable=pin","Info:   0 out of   2 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   1 third-party GitHubAction dependencies pinned","Info:   1 out of   1 npmCommand dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE.md:0","Info: FSF or OSI recognized license: MIT License: LICENSE.md:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 18 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":4,"reason":"6 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-968p-4wvh-cqc8","Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275","Warn: Project is vulnerable to: GHSA-9wv6-86v2-598j","Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw","Warn: Project is vulnerable to: GHSA-j8xg-fqg3-53r7"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-16T18:12:11.598Z","repository_id":30271087,"created_at":"2025-08-16T18:12:11.598Z","updated_at":"2025-08-16T18:12:11.598Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28947604,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-31T14:26:55.697Z","status":"ssl_error","status_checked_at":"2026-01-31T14:26:52.545Z","response_time":128,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dijkstra","node-graph","nodejs"],"created_at":"2026-01-31T16:30:05.378Z","updated_at":"2026-01-31T16:30:06.423Z","avatar_url":"https://github.com/albertorestifo.png","language":"JavaScript","readme":"# node-dijkstra\n\n[![Unit Tests](https://github.com/albertorestifo/node-dijkstra/actions/workflows/test.yml/badge.svg)](https://github.com/albertorestifo/node-dijkstra/actions/workflows/test.yml) [![codecov.io](http://codecov.io/github/albertorestifo/node-dijkstra/coverage.svg?branch=master)](http://codecov.io/github/albertorestifo/node-dijkstra?branch=master)\n\n\u003e Fast JavaScript implementation of the Dijkstra's shortest path problem for NodeJS\n\n## Installation\n\nSince version 2 this plugin uses some ES6 features. You can run the latest version on **NodeJS `v4.0.0` or newer**\n\n```shell\nnpm install node-dijkstra --save\n```\n\n### NodeJS prior `v4.0.0`\n\nOn versions of NodeJS prior `v4.0.0`, although less performant, it's safe to use the version `1.1.3` that you can install as follows:\n\n```shell\nnpm install node-dijkstra@1.1.3 --save\n```\n\nYou can then refer to the [`v1.1.3` documentation](https://github.com/albertorestifo/node-dijkstra/blob/v1.1.3/README.md#api)\n\n## Usage\n\nBasic example:\n\n```js\nconst Graph = require(\"node-dijkstra\");\n\nconst route = new Graph();\n\nroute.addNode(\"A\", { B: 1 });\nroute.addNode(\"B\", { A: 1, C: 2, D: 4 });\nroute.addNode(\"C\", { B: 2, D: 1 });\nroute.addNode(\"D\", { C: 1, B: 4 });\n\nroute.path(\"A\", \"D\"); // =\u003e [ 'A', 'B', 'C', 'D' ]\n```\n\n## API\n\n### `Graph([nodes])`\n\n#### Parameters\n\n- `Object|Map nodes` _optional_: Initial nodes graph.\n\nA nodes graph must follow this structure:\n\n```\n{\n  node: {\n    neighbor: cost Number\n  }\n}\n```\n\n```js\n{\n  'A': {\n    'B': 1\n  },\n  'B': {\n    'A': 1,\n    'C': 2,\n    'D': 4\n  }\n}\n```\n\n#### Example\n\n```js\nconst route = new Graph();\n\n// or with pre-populated graph\nconst route = new Graph({\n  A: { B: 1 },\n  B: { A: 1, C: 2, D: 4 },\n});\n```\n\nIt's possible to pass the constructor a deep `Map`. This allows using numbers as keys for the nodes.\n\n```js\nconst graph = new Map();\n\nconst a = new Map();\na.set(\"B\", 1);\n\nconst b = new Map();\nb.set(\"A\", 1);\nb.set(\"C\", 2);\nb.set(\"D\", 4);\n\ngraph.set(\"A\", a);\ngraph.set(\"B\", b);\n\nconst route = new Graph(graph);\n```\n\n### `Graph#addNode(name, edges)`\n\nAdd a node to the nodes graph\n\n#### Parameters\n\n- `String name`: name of the node\n- `Object|Map edges`: object or `Map` containing the name of the neighboring nodes and their cost\n\n#### Returns\n\nReturns `this` allowing chained calls.\n\n```js\nconst route = new Graph();\n\nroute.addNode(\"A\", { B: 1 });\n\n// chaining is possible\nroute.addNode(\"B\", { A: 1 }).addNode(\"C\", { A: 3 });\n\n// passing a Map directly is possible\nconst c = new Map();\nc.set(\"A\", 4);\n\nroute.addNode(\"C\", c);\n```\n\n### `Graph#removeNode(name)`\n\nRemoves a node and all its references from the graph\n\n#### Parameters\n\n- `String name`: name of the node to remove\n\n#### Returns\n\nReturns `this` allowing chained calls.\n\n```js\nconst route = new Graph({\n  a: { b: 3, c: 10 },\n  b: { a: 5, c: 2 },\n  c: { b: 1 },\n});\n\nroute.removeNode(\"c\");\n// =\u003e The graph now is:\n// {\n//   a: { b: 3 },\n//   b: { a: 5 },\n// }\n```\n\n### `Graph#path(start, goal [, options])`\n\n#### Parameters\n\n- `String start`: Name of the starting node\n- `String goal`: Name of out goal node\n- `Object options` _optional_: Addittional options:\n  - `Boolean trim`, default `false`: If set to true, the result won't include the start and goal nodes\n  - `Boolean reverse`, default `false`: If set to true, the result will be in reverse order, from goal to start\n  - `Boolean cost`, default `false`: If set to true, an object will be returned with the following keys:\n    - `Array path`: Computed path (subject to other options)\n    - `Number cost`: Total cost for the found path\n  - `Array avoid`, default `[]`: Nodes to be avoided\n\n#### Returns\n\nIf `options.cost` is `false` (default behaviour) an `Array` will be returned, containing the name of the crossed nodes. By default it will be ordered from start to goal, and those nodes will also be included. This behaviour can be changes with `options.trim` and `options.reverse` (see above)\n\nIf `options.cost` is `true`, an `Object` with keys `path` and `cost` will be returned. `path` follows the same rules as above and `cost` is the total cost of the found route between nodes.\n\nWhen to route can be found, the path will be set to `null`.\n\n```js\nconst Graph = require(\"node-dijkstra\");\n\nconst route = new Graph();\n\nroute.addNode(\"A\", { B: 1 });\nroute.addNode(\"B\", { A: 1, C: 2, D: 4 });\nroute.addNode(\"C\", { B: 2, D: 1 });\nroute.addNode(\"D\", { C: 1, B: 4 });\n\nroute.path(\"A\", \"D\"); // =\u003e ['A', 'B', 'C', 'D']\n\n// trimmed\nroute.path(\"A\", \"D\", { trim: true }); // =\u003e [B', 'C']\n\n// reversed\nroute.path(\"A\", \"D\", { reverse: true }); // =\u003e ['D', 'C', 'B', 'A']\n\n// include the cost\nroute.path(\"A\", \"D\", { cost: true });\n// =\u003e {\n//       path: [ 'A', 'B', 'C', 'D' ],\n//       cost: 4\n//    }\n```\n\n## Upgrading from `v1`\n\n- The `v2` release in not compatible with NodeJS prior to the version 4.0\n- The method `Graph#shortestPath` has been deprecated, use `Graph#path` instead\n- The method `Graph#addVertex` has been deprecated, use `Graph#addNode` instead\n\n## Releases\n\nThis package uses automated releases to NPM via GitHub Actions. When a new [GitHub release](https://github.com/albertorestifo/node-dijkstra/releases) is published, the package is automatically published to NPM after running the test suite.\n\nTo create a new release:\n1. Update the version in `package.json`\n2. Create a new [GitHub release](https://github.com/albertorestifo/node-dijkstra/releases/new) with a tag matching the version\n3. The GitHub Actions workflow will automatically publish to NPM\n\n## Testing\n\n```shell\nnpm test\n```\n\n[![js-standard-style](https://cdn.rawgit.com/feross/standard/master/badge.svg)](https://github.com/feross/standard)\n\n[1]: https://github.com/andrewhayward/dijkstra\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falbertorestifo%2Fnode-dijkstra","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falbertorestifo%2Fnode-dijkstra","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falbertorestifo%2Fnode-dijkstra/lists"}