Skip to content

fanqingsong/dijistra_algorithm.js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

dijistra algorithm library

this project is for develop dijistra library

The main module return a dijistra alogrithm Class (DIJISTRA_ALGORITHM)

including one api temporily

  • ComputeShortPath

#install and run

npm install
npm run build

// to build the distribution
npm run build

// to see the usage
cd example
npm install
npm run dev

explain

usage code


const { DIJISTRA_ALGORITHM } = require("dijistra");

function DocWrite(str)
{
    document.write(str);
    document.write("<br>");
}

//有向无环图
var DAG = {
  "welecome": {"adjacentTo": ["service"]},
  "service": {"adjacentTo": ["phone", "brandband"]},
  "phone": {"adjacentTo": ["over"]},
  "brandband": {"adjacentTo": ["over"]},
  "over": {"adjacentTo": []}
};

DocWrite("DAG="+JSON.stringify(DAG));

let dijistraInstance = new DIJISTRA_ALGORITHM(DAG, "welecome", "OVER");

var ret = dijistraInstance.ComputeShortPath();

DocWrite("distance [welecome, OVER]="+ret.distance);


About

implement dijistra shortest path computation using javascript

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published