UNPKG

a-star-for-async-data

Version:

A* search algorithm for asynchronous data sources

29 lines (28 loc) 1.19 kB
export declare type GraphNode = string; export interface IGraphEdge { from: GraphNode; to: GraphNode; cost: number; } export declare type GoalFunction = (_: GraphNode) => boolean; export declare type Goal = GraphNode | GoalFunction; export interface IAstarOptions<T extends IGraphEdge> { exitArcsForNodeId?: (f: GraphNode) => T[]; h?: (f: GraphNode, t: GraphNode) => number; } export interface IGraphPath<T extends IGraphEdge = IGraphEdge> { cost: number; path: T[]; } export declare class Astar<T extends IGraphEdge = IGraphEdge> { constructor(customCallbackFuncs?: IAstarOptions<T>); h(from: GraphNode, to: GraphNode): number; lookupH(from: GraphNode, to: GraphNode): Promise<number>; exactMatchGoalFunc(goalNodeId: GraphNode): (testNodeId: string) => Promise<boolean>; cleanGoalFunc(goalOrGoalFunc: Goal): (testNodeId: string) => Promise<boolean>; exitArcsForNodeId(nodeId: GraphNode): T[]; lookupExitArcsForNodeId(nodeId: GraphNode): Promise<T[]>; private findPathGenerator(startNodeId, goalOrGoalFunc); findPath(startNodeId: GraphNode, goalFunc: Goal): Promise<IGraphPath<T>>; static Debug: () => typeof Astar; }