Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Module

x/lazy_pathfinding/directed/a_star.ts>aStarBag

Pathfinding library for Deno
Latest
function aStarBag
import { aStarBag } from "https://deno.land/x/lazy_pathfinding@v1.1.1/directed/a_star.ts";

Compute all shortest paths using the A* search algorithm. Whereas aStar (non-deterministic-ally) returns a single shortest path, aStarBag returns all shortest paths (in a non-deterministic order).

Multiple equivalent nodes (determined by the AStarOptions.key() function) will never be included twice in the path.

The shortest paths starting from AStarOptions.start up to a node for which AStarOptions.success() returns true are computed and returned in an iterable along with the cost (which, by definition, is the same for each shortest path). If no paths are found, undefined is returned. Each path comprises both the start and an end node. Note that while every path shares the same start node, different paths may have different end nodes.

Type Parameters

Node
optional
Cost = number

Returns

[Iterable<Node[]>, Cost] | undefined