简体   繁体   English

使用Dijkstra或Bellman-Ford算法修改最短路径

[英]Modified shortest path using Dijkstra's or Bellman–Ford's algorithm

How can we use Dijkstra's or Bellman–Ford's algorithm to find shortest path in a graph whose some of edges are affected if we go specific vertices. 我们如何使用Dijkstra或Bellman-Ford算法在图中找到最短路径,如果我们去特定顶点,其中一些边会受到影响。 Such that, the affected edge's length will be more than or less than the original length. 这样,受影响的边缘的长度将大于或小于原始长度。

If I understand this right, you want to change the cost of an edge in a graph depending on nodes which are visited in your current path. 如果我理解这一点,您希望根据当前路径中访问的节点更改图表中边缘的成本。 An example from the comments is: 评论的一个例子是:

"Edge AB has length 3, but if you also visit node C, AB's length will be 5" “Edge AB的长度为3,但如果您还访问节点C,则AB的长度为5”

Now, there doesn't seem to be a way for something like Djikstra's algorithm to be used as there is a greedy step in that algorithm which picks the 'best' node at every stage. 现在,似乎没有办法像Djikstra的算法那样使用,因为在该算法中有一个贪婪的步骤,它在每个阶段选择“最佳”节点。 The notion that the 'best' node at that point may change at a later time (due to a rule such as above) violates the concept of the greedy approach which assumes that we are effectively visiting nodes in order from best to worst cost. 此时“最佳”节点可能在以后发生变化(由于上述规则)这一概念违反了贪婪方法的概念,该方法假设我们按照从最佳到最差的成本有效地访问节点。 I'm not certain if this is NP hard as suggested but it certainly cannot use a Dijikstra kind of approach from the start. 我不确定这是否是NP硬的建议,但它肯定不能从一开始就使用Dijikstra方法。 +1 for the problem though. 但问题是+1。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用C ++和STL实现Dijkstra的最短路径算法 - Implementing Dijkstra's shortest path algorithm using C++ and STL Dijkstra最短路径算法问题 - Dijkstra's Shortest Path Algorithm issue Dijkstra寻找最短路径的算法? - Dijkstra's algorithm for finding the shortest path? 修改Dijkstra的算法以在最短路径中打印节点 - Modifying Dijkstra's algorithm to print the nodes in the shortest path Bellman-Ford算法中的堆栈溢出和分段错误11 - Stack Overflow and Segmentation Fault 11 in Bellman-Ford's Algorithm 使用 Dijkstra 算法跟踪两个节点之间的最短路径 - Keeping track of the shortest path between two nodes using Dijkstra's algorithm Dijkstra 的最短路径算法实现出错(使用 C++ STL) - Error in Dijkstra's shortest path algorithm implementation (using C++ STL) 如何使用 bellman-ford 算法返回所有具有捆绑权重的最短路径? - How can I return all the shortest paths with tied weight using bellman-ford algorithm? dijkstra最短路径算法的时间复杂度是否取决于所使用的数据结构? - Does time complexity of dijkstra's algorithm for shortest path depends on data structure used? 我在OpenMP中实现Dijkstra最短路径算法的范围可能有问题吗? - Possible scope issues with my implementation of Dijkstra's shortest path algorithm in OpenMP?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM