0

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:

  1. 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.
  2. 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.

DiscoFever
  • 123
  • 8
  • I have not worked on something like this before, but I would also look more into Floyd's because you will not need to recompute everything if you change the source unlike in Dijkstra's or A*. As the points do not change often I think this would make it more appealing. – MathBunny Jul 18 '16 at 18:42
  • What kind of heuristic are you planning to use? – Austin Jul 21 '16 at 02:41
  • I think I will start with Floyd's and do some testing with that algorithm to see if it's scales for a realistic price. If all that's OK I will stick with that. – DiscoFever Jul 25 '16 at 07:58
  • The preferred approach for shortest path problems in road maps is a bidirectional Dijkstra with precomputation of the search graph. What I don't get is that you have two metrics (time and distance). Do you want to calculate the shortest path, the fastest path, a compromise path...? – FrankS101 Jul 25 '16 at 12:34
  • In some instances 2 paths may exist (most often a shortest & fastest). In those occasions I want to show both. The driver has the liberty to choose the one he prefers. (just like google maps will show you multiple options of which by default one is chosen) – DiscoFever Jul 26 '16 at 13:11

0 Answers0