简体   繁体   English

加权有向图的最大成本和路径算法

[英]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.

相关问题 有向非循环图中两个顶点之间的最大加权路径 - Maximum weighted path between two vertices in a directed acyclic Graph 有向加权边缘图及其权重的算法 - Algorithm for directed weighted edge graphs and their weights 有向图中的Prims和Bellman-Ford算法 - Prims and Bellman-Ford Algorithms in Directed Graphs 加权有向图中的最短路径 - Shortest path in weighted directed graph 拓扑排序的加权有向非循环图上的最长路径搜索,但有效路径的最大边数 - Longest path search on a topologically sorted weighted directed acyclic graph, but with a maximum edge count for valid paths 在线性时间内找到有向图中边的最大成本差异的路径 - Find path with maximum cost difference of edges in directed graph in linear-time 在加权无向图中找到一条具有多项式时间最大代价的简单路径吗? 是NP吗? - Is finding a simple path in a weighted undirected graph with maximum cost in polynomial time? Is it NP? 在具有相同数量的顶点和边NP-Complete的加权无向图中找到具有最大成本的简单路径的问题吗? - Is the problem of finding the simple path with maximum cost in a weighted undirected graph with the same number of vertex and edges NP-Complete? 最大加权跨越弱连接DAG的算法 - Algorithms for maximum weighted spanning weakly connected DAG 矩阵中的最大路径成本 - Maximum path cost in matrix
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM