// Find an A path between two nodes in this collection's subgraph
eles.aStar(options?: AStarOptions): AStarResultFind an A* path between two nodes in this collection's subgraph. The heuristic defaults to zero, reducing the search to Dijkstra's ordering. The search closes nodes without reopening them; shortest-path guarantees require non-negative costs and a consistent heuristic. The library does not validate those mathematical properties.
| Name | Description |
|---|---|
options: AStarOptions? |
|
Fields of options
| Name | Description |
|---|---|
root: Collection | null? | |
goal: Collection | null? | |
weight: WeightFn? | |
heuristic: AStarHeuristicFn? | |
directed: boolean? |
AStarResult{ found, distance, path, steps }; when no path exists, found is false and distance and path are undefined
Example
const result = eles.aStar({ root: cy.getElementById('a'), goal: cy.getElementById('c'), weight: edge => edge.data('weight') });console.log(result.distance); // 5if root or goal is missing or outside this collection