I've got a graph were each vertex represents a city. (identified by lat, lng properties) In between the vertexes (cities) are weighted edges, these represent predefined routes in between the cities. In between some vertexes we have multiple edges (eg. shortest and fastest route). I already defined 10K+ vertexes and potentially more will be added in the future. Vertexes and edges won't change often once they're defined.
Users need to be able to calculate the shortest route in between any 2 of the vertexes.
I'm now considering which "shortest path algorithm" would work best for me. 2 possible solutions came to mind:
- Floyd's algorithm where I would store the resulting tables. Pro: Fast response times. CON: Takes a lot of memory when loaded in memory, don't even know if this would be reasonable as a cost.
- A* algorithm where I would create a subset of relevant vertexes before I start the algorithm. Example: user chooses vertex A & F. I check how far A & F are apart based on Lat, Lng properties. I add this distance on all sides of both A & F vertexes and identify all vertexes in this area. I do the algorithm with this subset of vertexes.
I'm looking for some advice on what would be the best solution. My preference goes to 1). If somebody did this before and could give some insight on the required infrastructure this would certainly help me.