I'm struggling to find the exact answer to my problem. I have a 20 by 20 grid. I am looking for a PHP code example, formula or the correct name of the algorithm needed to find out the following:
- Shortest route between 2 points that also passes through 1 of a few other pre defined points
- The route does not have to return to the origin at the end
- The route is allowed to pass diagonally between cells
- The origin and destination is set
So say my grid runs from A to T horizontally and 1 to 20 vertically. I am looking to calculate the shortest route from my origin A5 to my destination G12, whilst passing through either C7, D9, E5 or J8 based on whatever is the shortest overall route.
Additionally, it would be handy to know how to extend this so it not only passes through one point but perhaps 2, on its way to the destination (G12).
I have searched 2 days and my mind is now swirling with Dijkstra, TSP, BFS and the rest!
Thankyou!