与两个顶点和边费用最短路径算法

编程入门 行业动态 更新时间:2024-10-25 05:28:31
本文介绍了与两个顶点和边费用最短路径算法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

这是一个普遍的算法问题。我想在一个无向图,其中两个边和顶点具有与其相关的成本运行一些最短路径算法。大多数的最短路径寻找算法没有考​​虑顶点的成本考虑在内。有没有什么方法来弥补这个问题呢?

This is a general algorithm question. I want to run some shortest path algorithm on an undirected graph where both edges and vertices have costs associated with them. Most of the shortest path finding algorithms do not take the vertex costs into account. Is there any method to compensate this problem?

推荐答案

增广图表通过将两个顶点的边缘连接到边的成本的一半的成本(称之为边缘的增强成本)。

Augment the graph by adding half the cost of the two vertices an edge connects to the cost of the edge (call that the augmented cost of the edge).

则忽略顶点成本,对增强图形运行一个普通的最短路径算法。

Then ignore the vertex costs and run an ordinary shortest path algorithm on the augmented graph.

对于每个路径

v_0 -e_1-> v_1 -e_2-> v_2 -e_2-> ... -e_n-> v_n

成本的增加图为

the cost in the augmented graph is

(1/2*C(v_0) + C(e_1) + 1/2*C(v_1)) + (1/2*C(v_1) + C(e_2) + 1/2*C(v_2)) + ... + (1/2*C(v_(n-1)) + C(e_n) + 1/2*C(v_n)) = C(v_0) + C(e_1) + C(v_1) + C(e_2) + ... + C(e_n) + C(v_n) - 1/2*(C(v_0 + C(v_n))

因此​​两个顶点之间的路径成本 A 和 B 的增强图形是的费用相同的路径中的原始图形减去的开始和结束顶点的一半结合成本

so the cost of a path between two vertices a and b in the augmented graph is the cost of the same path in the original graph minus half the combined cost of the start and end vertices.

因此​​,一个路径是在原始图中的最短路径,当且仅是在增强图形的最短路径。

Thus a path is a shortest path in the original graph if and only it is a shortest path in the augmented graph.

更多推荐

与两个顶点和边费用最短路径算法

本文发布于:2023-11-30 15:08:26,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1650449.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:最短   顶点   算法   路径   费用

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!