I need to write a JavaScript algorithm to find the shortest path between 2 co-ordinates. I have looked at using a few route finding algorithms, such as the A* algorithm.
The difference in my application however is that I know all of the co-ordinates that the path can take.
For example, in the image below, the green square would be the starting place co-ord, with the red square being the end place co-ord. The co-ord represented by every black square would be stored in an an array (or other data structure).
So I need the shortest path from the green square, to the red square, but it can only pass through a black square to get there. Would I still use the A* algorithm to implement this?