[英]Maximum cost and path algorithms for weighted directed graphs
What algorithms are there, for weighted directed graphs, to find the maximum cost and path for going from a vertex A to a vertex K ? 对于加权有向图,有什么算法可以找到从顶点A到顶点K的最大成本和路径?
I was thinking of modfied Dijkstra, but while watching and learning this algorithm, I found out it can't be used with negative weights and can't be used to find the maximum cost. 我当时在想修改过的Dijkstra,但是在观看和学习此算法时,我发现它不能与负权重一起使用,也无法找到最大成本。
You could use a modified version of the A* (A-star) algorithm. 您可以使用A *(A星)算法的修改版本。 I say modified but it wouldn't actually be modified.
我说已修改,但实际上不会被修改。 You just need an appropriate heuristic.
您只需要适当的启发式。 It is a path finding algorithm, you would just need to set your heuristic to chooses the costliest path.
这是一种寻路算法,您只需要设置启发式方法即可选择最昂贵的路径。
A* works by starting at some vertex V, and adding all of that vertex's adjacent neighbors to an open list. A *的工作方式是从某个顶点V开始,然后将该顶点的所有相邻邻居添加到一个开放列表中。 Then it moves, in your case, to the node with the highest cost.
然后,在您的情况下,它将移动到成本最高的节点。 The previously visited node is moved to a closed list.
先前访问的节点将移至关闭列表。 Then all the adjacent nodes to the current node are added to the open list.
然后,当前节点的所有相邻节点都将添加到打开列表中。 And so on and so forth.
等等等等。
It will find your K, and if your heuristic is to always choose the costliest path, you will have the maximum cost route. 它会找到您的K,并且如果您的试探法总是选择最昂贵的路径,那么您将拥有最大的成本路径。
Here is A* being applied to Infinite Mario . 这是A *被应用到Infinite Mario 。
I suggest the following: choose any algorithm for minimum cost(distance) and also works with negative edges (thus Dijkstra can not be used for this). 我建议以下内容:选择任何算法以最小化成本(距离),并且还可以处理负边缘 (因此Dijkstra不能用于此目的)。 Then run this algorithm using the negation of the cost for each edge.
然后使用对每个边的成本求和来运行此算法。 You can use Bellman–Ford algorithm for instance.
例如,您可以使用Bellman–Ford算法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.