6

We are developing an application, in which we will show some available houses for sale in google map. User can select any houses from the map and can find the shortest driving route between all the houses he/she selected.

Can any one please tell me how we can find the shortest route and can show that on the map? Is there any PHP based TSP library, that can help us to achieve what we are trying?

Jon
  • 428,835
  • 81
  • 738
  • 806
jose
  • 464
  • 4
  • 7
  • 20

3 Answers3

12

A Google search shows many results.

You could probably combine the two, choosing which to run based on the size of the graph.

As @Barbar points out in the comments, there is an existing app that does what you're attempting. There is a blog post explaining how it works.

moinudin
  • 134,091
  • 45
  • 190
  • 216
  • 1
    the burteforce algorithm use ~300mb ram for 8 cities, and >2GB ram for 10 cities :O on my test data, anyway ; also, the generic algorithm url is 404 – hanshenrik Mar 03 '15 at 18:33
2

Its old but it may be useful to people: https://developers.google.com/maps/documentation/javascript/v2/services#RoutesAndSteps

just create waypoints for each house and let google do the math for you...

Feras
  • 2,114
  • 3
  • 20
  • 42
0

If the problem satisfy the triangle inequality you can try the Christofides algorithm.

Micromega
  • 12,486
  • 7
  • 35
  • 72