A high-performance TypeScript pathfinding library implementing multiple algorithms including Dijkstra and A* (A-star).
- Multiple pathfinding algorithms:
- Dijkstra's Algorithm
- A* (A-starAlgorithm
- Flexible graph representation
- Type-safe with full TypeScript support
- Comprehensive test coverage
- Performance benchmarking tools
- Detailed documentation
npm install pathfindr
import { Graph, AStar, Dijkstra } from 'pathfindr';
// Create a graph
const graph = new Graph();
// Add some edges
graph.addEdge('A', 'B', 4);
graph.addEdge('A', 'C', 2);
graph.addEdge('B', 'D', 3);
graph.addEdge('C', 'D', 1);
// Find shortest path using Dijkstra's algorithm
const path = Dijkstra.findShortestPath(graph, 'A', 'D');
console.log(path.path); // ['A', 'C', 'D']
console.log(path.totalCost); // 3
For detailed documentation, see:
The library supports custom configurations for pathfinding:
const options = {
maxIterations: 1000,
heuristic: (a: string, b: string=> {
// Custom heuristic function for A*
return 0;
},
};
const path = AStar.findShortestPath(graph, 'start', 'end', options);
Benchmarks comparing different algorithms are available in the benchmarks
directory. Run them using:
npm run benchmark
We welcome contributions! Please see our [Contributing Guide](./docs/contributing.mdfor details.
MIT
- Open an issue for bugs/feature requests
- Star the repo if you find it useful!
Repository: https://github.com/Ojochogwu866/pathfindr