You may use dijkstra algorithm for this, though A* has an advantage but dijkstra has more resources. A* for me is harder to understand.
You can create static nodes or vertices and use them for dijkstra. Just traverse on the nodes, and make sure that you can measure the distance of each node or vertex so that you can compare the shorter one, then eventually you can have the shortest path. You may create a map that contains nodes or vertices with distances for each related vertices to help you program. This is a bit of a challenge.
I don't have my codes right now but I guess the net can better help you. Good luck with this. Happy coding.