{"id":31904801,"url":"https://github.com/j50n/deno-dijkstras-algorithm","last_synced_at":"2025-10-13T13:59:36.557Z","repository":{"id":62422489,"uuid":"442032792","full_name":"j50n/deno-dijkstras-algorithm","owner":"j50n","description":"A fast and memory-efficient implementation of Dijkstra's shortest-path algorithm for Deno.","archived":false,"fork":false,"pushed_at":"2022-01-25T05:01:23.000Z","size":34,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-09-09T09:11:16.719Z","etag":null,"topics":["algorithm","deno","dijkstra","path","shortest"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/j50n.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-12-27T02:48:41.000Z","updated_at":"2022-01-25T04:07:59.000Z","dependencies_parsed_at":"2022-11-01T17:33:15.999Z","dependency_job_id":null,"html_url":"https://github.com/j50n/deno-dijkstras-algorithm","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/j50n/deno-dijkstras-algorithm","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/j50n%2Fdeno-dijkstras-algorithm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/j50n%2Fdeno-dijkstras-algorithm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/j50n%2Fdeno-dijkstras-algorithm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/j50n%2Fdeno-dijkstras-algorithm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/j50n","download_url":"https://codeload.github.com/j50n/deno-dijkstras-algorithm/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/j50n%2Fdeno-dijkstras-algorithm/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279015368,"owners_count":26085687,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-13T02:00:06.723Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["algorithm","deno","dijkstra","path","shortest"],"created_at":"2025-10-13T13:59:19.214Z","updated_at":"2025-10-13T13:59:36.552Z","avatar_url":"https://github.com/j50n.png","language":"TypeScript","readme":"# Dijkstra's Shortest Path Algorithm\n\nA fast and memory-efficient implementation of Dijkstra's shortest-path algorithm\nfor Deno.\n\nThis implementation of Dijkstra'a algorithm is able to process large in-memory\ngraphs. It will perform reasonably well even with millions of edges. The\nperformance is `O(n*log(n))`, where `n` is proportional to the number of nodes\nplus the number of edges in the graph. The use of integers to represent nodes in\nthe graph is intentional and actually one of the keys to its performance and\nscalability.\n\nThis code was adapted to Typescript from\n[A Walkthrough of Dijkstra's Algorithm (In JavaScript!)](https://medium.com/@adriennetjohnson/a-walkthrough-of-dijkstras-algorithm-in-javascript-e94b74192026)\non Medium. This implemetation was originally part of\n[BlackholeSuns](https://github.com/j50n/blackholesuns), an open source project\nthat allowed thousands of No Man's Sky players to navigate the galaxy using\nmapped black holes. This version is cleaned up a bit and includes a few bug\nfixes and more tests than the original. See also\n[Dijkstra's algorithm](https://en.wikipedia.org/wiki/Dijkstra%27s_algorithm) on\nWikipedia.\n\n# Documentation\n\n```sh\ndeno doc --reload https://deno.land/x/dijkstras_algorithm/dijkstra.ts\n```\n\n# Run Tests\n\n```sh\ndeno test --reload\n```\n\n# Usage Hints\n\nDijkstra's algorithm calculates the shortest _paths_ from the start node to\n_all_ other nodes in the graph. All of them. In other words, it isn't just\ncalculating one path at a time. This can let you cheaply do things like find the\n20 closest nodes from a particular node in the graph, for example.\n\nOne you have loaded a graph definition into a solver, you can clone it. You can\nthen add nodes to the cloned graph. Loading a large graph over and over takes\ntime, and depending on overhead, this can be even slower than calculating the\nshortest paths. This type of reuse lets you get super-fast results.\n\n# Example\n\nThis example recreates the example from the article referenced earlier. The\nnodes are mapped to integers from `0` to `n-1`. The names and weights are taken\nfrom\n[A Walkthrough of Dijkstra's Algorithm (In JavaScript!)](https://medium.com/@adriennetjohnson/a-walkthrough-of-dijkstras-algorithm-in-javascript-e94b74192026).\n\n![Example Graph](https://miro.medium.com/max/2400/1*lTVbpbmx3OWbKSWLp7M3ug.jpeg)\n\n```ts\nconst FULLSTACK = 0;\nconst DIGINN = 1;\nconst DUBLINER = 2;\nconst STARBUCKS = 3;\nconst CAFEGRUMPY = 4;\nconst INSOMNIACOOKIES = 5;\n\nconst cafes = DijkstraShortestPathSolver.init(6);\n\ncafes.addBidirEdge(DIGINN, FULLSTACK, 7);\ncafes.addBidirEdge(FULLSTACK, STARBUCKS, 6);\ncafes.addBidirEdge(DIGINN, DUBLINER, 4);\ncafes.addBidirEdge(FULLSTACK, DUBLINER, 2);\ncafes.addBidirEdge(DUBLINER, STARBUCKS, 3);\ncafes.addBidirEdge(DIGINN, CAFEGRUMPY, 9);\ncafes.addBidirEdge(CAFEGRUMPY, INSOMNIACOOKIES, 5);\ncafes.addBidirEdge(DUBLINER, INSOMNIACOOKIES, 7);\ncafes.addBidirEdge(STARBUCKS, INSOMNIACOOKIES, 6);\n\nassertEquals(\n  cafes.calculateFor(FULLSTACK).shortestPathTo(CAFEGRUMPY),\n  [FULLSTACK, DUBLINER, INSOMNIACOOKIES, CAFEGRUMPY],\n);\n\nassertEquals(\n  cafes.calculateFor(FULLSTACK).weightOfPathTo(CAFEGRUMPY),\n  14,\n);\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fj50n%2Fdeno-dijkstras-algorithm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fj50n%2Fdeno-dijkstras-algorithm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fj50n%2Fdeno-dijkstras-algorithm/lists"}