justjavac / deno_dijkstra

A simple JavaScript implementation of Dijkstra's single-source shortest-paths algorithm.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

deno_dijkstra

tag ci license

A simple JavaScript implementation of Dijkstra's single-source shortest-paths algorithm.

Base on tcort/dijkstrajs

Usage

import dijkstra from "https://deno.land/x/dijkstra/mod.ts";

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 path = dijkstra.find_path(graph, "a", "i"); // ["a", "d", "e", "f", "i"]

Example

deno run https://deno.land/x/dijkstra/example.ts

License

deno_dijkstra is released under the MIT License. See the bundled LICENSE file for details.

About

A simple JavaScript implementation of Dijkstra's single-source shortest-paths algorithm.

License:MIT License


Languages

Language:TypeScript 100.0%