fp-search-algorithms
Version:
Functional Programming Style Search Algorithms and Unordered Containers
34 lines (33 loc) • 1.69 kB
TypeScript
/**
* Performs `k` best-first searches using Yen's algorithm
* Returns an array of `{ cost: number; path: T[] }`
* If array has less then k items, there were less than that many total paths to the solution
* If an empty array is returned, there are zero paths to the solution
*
* @category Yen
* @param getNextStates - a function to generate list of neighboring states with associated transition costs given the current state
* @param determineIfFound - a function to determine if solution found
* @param initial - initial state
* @param k - number of shortest paths to find, returned in order of shortest
*/
export declare const yenAssoc: <T>(getNextStates: (state: T) => [T, number][], determineIfFound: (state: T) => boolean, initial: T, k: number) => {
cost: number;
path: T[];
}[];
/**
* Performs `k` best-first searches using Yen's algorithm
* Returns an array of `{ cost: number; path: T[] }`
* If array has less then k items, there were less than that many total paths to the solution
* If an empty array is returned, there are zero paths to the solution
*
* @category Yen
* @param getNextStates - a function to generate list of neighboring states given the current state
* @param getCost - a function to generate transition costs between neighboring states
* @param determineIfFound - a function to determine if solution found
* @param initial - initial state
* @param k - number of shortest paths to find, returned in order of shortest
*/
export declare const yen: <T>(getNextStates: (state: T) => T[], getCost: (from: T, to: T) => number, determineIfFound: (state: T) => boolean, initial: T, k: number) => {
cost: number;
path: T[];
}[];