node-astar
A* search algorithm implementation
This is a generic asynchronous implementation of the A* search algorithm to be user together with databases such as mongodb, elastic, etc.
The algorithm is based on an article of Brian Grinstead found named A* Search Algorithm in JavaScript
usage
- Each node is a Astar.Node object with an unique id, a latitude and a longitude.
const Astar = ; const n1 = Astar;const n2 = Astar;
-
Create a function for getting the neighbours of a node.
The function get two parameters: the current node and the method to call once the neighbours are retrived.
You have to pass an array of Astar.Node objects to the callback.
const findNeighbours = { mongodb;}
- Create a Astar object passing the neighbours function as a parameter
var astar = findNeighbours;
- Search for the sorted route pasing the start and end nodes. As a result you get the list of nodes or empty if not path found
astar;