algorithm - 向图的所有边添加权重 - 生成树和最短路径的变化

标签 algorithm graph

<分区>

(a) Let T be a minimum spanning tree of a weighted graph G. Construct a new graph G by adding a weight of k to every edge of G. Do the edges of T form a minimum spanning tree of G. Prove the statement or give a counterexample.

(b) Let P = {s, . . . , t} describe a shortest weighted path between vertices s and t of a weighted graph G. Construct a new graph G by adding a weight of k to every edge of G. Does P describe a shortest path from s to t in G. Prove the statement or give a counterexample.

我的解决方案:

a) T 的边仍然形成 G 的最小生成树,因为所有边的权重都增加了相同的量。

b) P仍然描述了G中s到t的最短路径(同理)

有人可以验证答案吗?

最佳答案

虽然我不认为 SO 是你问题的最佳位置,但你对问题 B 的回答肯定是错误的。

考虑一个具有 3 个顶点(A、B、C)和以下边的图:

A-B = 1
A-C = 0
C-B = 0

A 和 B 之间的最短加权路径是 A-C-B。如果将所有权重加 2,则最短路径变为 A-B。

(抱歉,错过了问题的第一部分,现在已经有答案了。a 正确而 b 错误的原因是生成树总是恰好包含 n-1 边,而最短加权路径中的边数可能会有所不同。)

关于algorithm - 向图的所有边添加权重 - 生成树和最短路径的变化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10790909/

相关文章:

algorithm - 如何在不反复试验的情况下逻辑地解决这个难题

python - 如何确定 Networkx 图表中所选节点的特定颜色和大小

Android:运行图的滚动条

c++ - 如何在无向图中找到遍历最多节点的路径?

python-3.x - 可视化链接攻击的最佳方式是什么

sql - Allen 在 SQL 中的区间代数运算

algorithm - 使用 LIFO 实现 FIFO

algorithm - 完整图分量数

algorithm - 方差的渐近运行时间是多少?

algorithm - 在二进制矩阵中分解和处理时间序列