Variations of Dijkstra's Algorithm for graphs with two weight properties

大兔子大兔子 提交于 2019-12-08 02:50:08

问题


I'm trying to find a heuristic for a problem that is mapped to a directed graph with say non-negative weight edges. However, each edge is associated with two weight properties as opposed to only one weight (e.g. say one is distance, and another one showing how good the road's 4G LTE coverage is!). Is there any specific variation of dijkstra, Bellman Ford, or any other algorithm that pursues this objective? Of course, a naive workaround is manually deriving a single weight property as a combination of all of them, but this does not look good.

Can it be generalized to cases with multiple properties?


回答1:


Say you want to optimize simultaneously two criteria: distance and attractiveness (and say path attractiveness is defined as the attractiveness of the most attractive edge, although you can think of different definitions). The following variation of Dijkstra can be shown to work, but I think it is mainly useful where one of the criteria takes a small number of values - say attractiveness is 1, ..., k for some small fixed k (smaller i is better).

The standard pseudocode for Dijsktra's algorithm uses a single priority queue. Instead use k priority queues. Priority queue i will correspond in Dijkstra's algorithm to the shortest path to a node v ∈ V with attractiveness i.

Start by initializing that each node is in each of the queues with distance (because, initially, the shortest path to v with attractiveness i is infinite).

In the main Dijkstra loop, where it says

 while Q is not empty

change it to

 while there is an i for which Q[i] is not empty
     Q = Q[i] for the lowest such i

and continue from there.

Note that when you update, you pop from queue Q[i], and insert to Q[j] for j ≥ i.

It's possible to modify the proof of Dijkstra's relaxation property to show that this works.

Note that you will obtain up to k |V| results, as per node and attractiveness, you can have the shortest distance to the node with the given attractiveness.

Example

Taking an example from the comments:

So basically if a path has a total no-coverage miles of >10, then we go for another path.

Here, e.g., assuming the miles are integers (or can be rounded to integers), we could create 11 queues: queue i corresponds to the shortest distance with i no-coverage miles, except for 10, which corresponds to 10-or-higher no-coverage-miles.

At some point of the algorithm, say all queues are empty below queue 3. We pop queue 3, and update the vertex's neighbors: this might update, e.g., some node in queue 4, if the distance from the popped node to the other node is 1.

As the algorithm runs, it outputs mappings of (node, no-coverage-distance) → shortest distance. Here, you could decide that you discard all mappings for which the second item in the pair is 10.



来源:https://stackoverflow.com/questions/35438749/variations-of-dijkstras-algorithm-for-graphs-with-two-weight-properties

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!