You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

astar-algorithm

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

astar-algorithm

An almost universal implementation of A* search algorithm in JavaScript

0.1.0
Source
npmnpm
Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

astar-algorithm

An almost universal implementation of A* search algorithm in JavaScript

NPM version Build status Test coverage

Requirements

  • ECMAScript 2015+

Usage

// 1) You need require the function
const astar = require('astar-algorithm')

// 2) You should define all callbacks
let callbacks = {
  // It should return id / key / hash for a node
  id(node) {
    // return {String} or what you want
  },
  // It checks: is a node is the goal?
  isGoal(node) {
    // return {Boolean}
  },
  // It should return an array of successors / neighbors / children
  getSuccessors(node) {
    // return {Array} of nodes
  },
  // g(x). It returns the cost of path between two nodes
  distance(nodeA, nodeB) {
    // return {Number}
  },
  // h(x). It returns the cost of path from a node to the goal
  estimate(node, goal) {
    // return {Number}
  }
}

// 3) Execute it!
let path = astar(start, goal, callbacks)

See examples there.

Keywords

best

FAQs

Package last updated on 22 Jul 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts