AStar(graph, source, target)

Implementation of the AStar algorithm.

new AStar(graph, source, target)

Constructs an AStar algorithm object.

Parameters:
Name Type Default Description
graph Graph null

The graph.

source Number

The node index of the source node.

target Number

The node index of the target node.

Author:

Members

found :Boolean

Whether the search was successful or not.

Default Value:
  • false

nullable graph :Graph

The graph.

Default Value:
  • null

heuristic :Object

The heuristic of the search.

Default Value:
  • HeuristicPolicyEuclid

source :Number

The node index of the source node.

Default Value:
  • - 1

target :Number

The node index of the target node.

Default Value:
  • - 1

Methods

clear() → {AStar}

Clears the internal state of the object. A new search is now possible.

Returns:
AStar -

A reference to this AStar object.

getPath() → {Array.<Number>}

Returns the shortest path from the source to the target node as an array of node indices.

Returns:
Array.<Number> -

The shortest path.

getSearchTree() → {Array.<Edge>}

Returns the search tree of the algorithm as an array of edges.

Returns:
Array.<Edge> -

The search tree.

Executes the graph search. If the search was successful, AStar#found is set to true.

Returns:
AStar -

A reference to this AStar object.