@graphty/algorithms / index / astar
Function: astar() ​
astar(
g,sourceNode,targetNode,heuristic,options?):AstarResult
Defined in: indexed/point-to-point.ts:214
A* between two nodes: Dijkstra keyed by cost so far plus heuristic(node, target), stopping when the target is taken from the queue. An expanded node is never reopened, as in legacy astar, so the path is shortest when the heuristic is consistent. The predecessor is the relaxing ARC, so a parallel edge on the path is the exact edge.
Parameters ​
g ​
AdjacencyView
The adjacency to search
sourceNode ​
NodeRef
The node to start from: its index, or { id }
targetNode ​
NodeRef
The node to reach: its index, or { id }
heuristic ​
(node, target) => number
Estimated remaining cost from a node index to the target index
options? ​
PathOptions = {}
Per-arc weight override
Returns ​
The path, plus the per-node scores and the expansion order