Search code examples
javaalgorithmpath-finding

Pathfinding algorithm with least amount of steps


I'm looking for some kind of path finding algorithm that does not only give me the shortest path. I want to get the shortest path with the least amount of steps.

Currently I'm using Dijkstra's Algorithm to get the shortest path, but I'm not stuck to this.

In my example, you have to stop at certain locations, that have a specific price. So I want to get the 'cheapest' route, but I also want to stop the least amount of times.


Solution

  • I saved it with adding a new int variable to my Vertex class. It's a step counter, that is being checked before looking at the cost and it's working!