What is a good algorithm, or class of algorithms that can be used to create a bus route?
I was thinking something along the lines of algorithms that are used to solve the Traveling Salesman, or Hamiltonian path problems, but in truth, neither really addresses the issue of how to move between two stops.
I would like the algorithm to have at least the following characteristics:
- produces a relatively optimized path (I understand that the problem is probably NP complete, so a good heuristic is fine)
- Can deal with parts of the path having different weights (eg time to travel over that part of the path)
- Can be forced to use a given starting and ending point (I don’t think this one will be such a problem)
Code that can do this, or something like this would be appreciated (especially in C#), but a good algorithm by itself would be fine.
Note: While there are many algorithms that can find the shortest path between two points, I do not know the order in which I wish to stop. As such, unless I should be using a combination of two algorithms (which I doubt is the case), those algorithms do not do what I want (if you think that they do, please explain).
Edit: Assume I know all of the stops that need to be made.
It seems that a way to do this involves using the Floyd-Warshall algorithm, and then using an algorithm that is used to solve the traveling salesman problem.
This solves the problem of all the “optional” vertices (the intersections) and the uses the traveling salesman algorithm to determine the order in which the stops should be hit.