3

I'm looking for an algorithm which I'm sure must have been studied, but I'm not familiar enough with graph theory to even know the right terms to search for.

In the abstract, I'm looking for an algorithm to determine the set of routes between reachable vertices [x1, x2, xn] and a certain starting vertex, when each edge has a weight and each route can only have a given maximum total weight of x.

In more practical terms, I have road network and for each road segment a length and maximum travel speed. I need to determine the area that can be reached within a certain time span from any starting point on the network. If I can find the furthest away points that are reachable within that time, then I will use a convex hull algorithm to determine the area (this approximates enough for my use case).

So my question, how do I find those end points? My first intuition was to use Dijkstra's algorithm and stop once I've 'consumed' a certain 'budget' of time, subtracting from that budget on each road segment; but I get stuck when the algorithm should backtrack but has used its budget. Is there a known name for this problem?

Roel
  • 19,338
  • 6
  • 61
  • 90
  • You're looking at the [maximum flow problem](https://en.wikipedia.org/wiki/Maximum_flow_problem). Did you want just the name of it or a rough analysis? – Makoto Jul 09 '15 at 21:40
  • Take a look on https://en.wikipedia.org/wiki/Maximum_coverage_problem an d to related question http://stackoverflow.com/questions/3859891/algorithm-for-maximizing-coverage-of-rectangular-area-with-scaling-tiles. – Mihai8 Jul 09 '15 at 21:41
  • @Makoto is it? From what I understand on maximum flow, it's only for finding one path from a given source to a given destination, with a maximum 'throughput'? – Roel Jul 12 '15 at 12:39
  • @user1929959 I'm not sure how that relates to my problem - I don't care about visiting as many links as possible, I just want the maximum distance from one given point. But I'm probably just not seeing the connections. – Roel Jul 12 '15 at 12:41

2 Answers2

3

If I understood the problem correctly, your initial guess is right. Dijkstra's algorithm, or any other algorithm finding a shortest path from a vertex to all other vertices (like A*) will fit.

In the simplest case you can construct the graph, where weight of edges stands for minimum time required to pass this segment of road. If you have its length and maximum allowed speed, I assume you know it. Run the algorithm from the starting point, pick those vertices with the shortest path less than x. As simple as that.

If you want to optimize things, note that during the work of Dijkstra's algorithm, currently known shortest paths to the vertices are increasing monotonically with each iteration. Which is kind of expected when you deal with graphs with non-negative weights. Now, on each step you are picking an unused vertex with minimum current shortest path. If this path is greater than x, you may stop. There is no chance that you have any vertices with shortest path less than x from now on.

If you need to exactly determine points between vertices, that a vehicle can reach in a given time, it is just a small extension to the above algorithm. As a next step, consider all (u, v) edges, where u can be reached in time x, while v cannot. I.e. if we define shortest path to vertex w as t(w), we have t(u) <= x and t(v) > x. Now use some basic math to interpolate point between u and v with the coefficient (x - t(u)) / (t(v) - t(u)).

Mikhail
  • 20,685
  • 7
  • 70
  • 146
  • Thanks, this answer (combined with @div's) set me on the right path. The thing I failed to realize becomes obvious when I reformulate the problem as follows: 'find all points that are *at most* a budget x from a given start vertex v1'. I'd have Dijkstra run on the whole graph, not stopping when a given end node is reached, but when the budget is exceeded. All visited vertices in my graph at that point have a budget lower than x, and my convex hull algorithm then culls all points within the boundary. (cont...) – Roel Jul 12 '15 at 12:51
  • This way, it would even cover some pathological cases where vertices later in the routes are closer (as in, carthesian distance closer) to the starting node (because the road makes a turn to get around an obstacle or lake), which would have made my 'region covered' smaller than required. Which is of course exactly what you said, but it didn't click with me until I worded it to myself the way I wrote it above :) – Roel Jul 12 '15 at 12:51
2

Using breadth first search from the starting node seems a good way to solve the problem in O(V+E) time complexity. Well that's what Dijkstra does, but it stops after finding the smallest path. In your case, however, you must continue collecting routes for your set of routes until no route can be extended keeping its weigth less than or equal the maximum total weight.

And I don't think there is any backtracking in Dijkstra's algorithm.

galath
  • 5,717
  • 10
  • 29
  • 41
div
  • 573
  • 5
  • 10
  • Thanks. You're right, my comment about the backtracking was because of my misunderstanding of the modified version of Dijkstra we use already, sorry about the confusion. – Roel Jul 12 '15 at 12:41