Socket
Socket
Sign inDemoInstall

astar-algorithm

Package Overview
Dependencies
0
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    astar-algorithm

An almost universal implementation of A* search algorithm in JavaScript


Version published
Weekly downloads
3
decreased by-50%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

astar-algorithm

An almost universal implementation of A* search algorithm in JavaScript.

NPM version Build status Test coverage

Requirements

  • ECMAScript 2015+

Usage

// 1)
const astar = require('astar-algorithm')

// 2)
let callbacks = {
  // It should return id / key / hash for a node
  id(node) {
    // return {String} or what you want
  },
  // It should check: 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 should return the cost of path between two nodes
  distance(nodeA, nodeB) {
    // return {Number}
  },
  // h(x). It should return the cost of path from a node to the goal
  estimate(node, goal) {
    // return {Number}
  }
}

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

See more examples there.

Keywords

FAQs

Last updated on 27 Jul 2017

Did you know?

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc