Skip to content

aStar

aStar<TNode>(start, traits): GraphPath<TNode> | null

Defined in: graph/a-star.ts:24

Finds the cheapest path from start to a goal, exploring by cost so far plus estimated cost remaining.

With no heuristicOf this is Dijkstra’s algorithm — the estimate is uniformly zero, so exploration is purely by cost so far. A heuristic that never overestimates keeps the result optimal while cutting how much of the graph gets visited; one that overestimates trades that guarantee for speed.

Time complexity: O((V + E) log V), and costOf must be non-negative.

TNode extends DefinedValue

TNode

The node to search from.

GraphSearchTraits<TNode>

How to expand, weight and test a node.

GraphPath<TNode> | null

The cheapest path and its cost, or null if no goal is reachable.