所有配对最短路径与动态规划
所有,
我正在阅读所有对最短路径和矩阵乘法之间的关系。
考虑加权邻接矩阵与 本身 - 除了在这种情况下,我们替换乘法运算 在矩阵乘法和加法中,以及加法运算 最小化。请注意,加权邻接矩阵的乘积 with 本身返回一个包含长度为 2 的最短路径的矩阵 任意一对节点之间。
从这个论证可以得出,A 的 n 次方包含所有最短路径。
问题 1:
我的问题是,在图中,路径中两个节点之间最多有 n-1 条边,作者在什么基础上讨论长度为“n”的路径?
以下幻灯片
www.infosun.fim.uni-passau.de/br/lehrstuhl/.../Westerheide2.PPT
上幻灯片 10 如下所述。
dij(1) = cij
dij(m) = min (dij(m-1), min1≤k≤n {dik(m-1) + ckj}) --> Eq 1
= min1≤k≤n {dik(m-1) + ckj} ------------------> Eq 2
问题2:作者是如何从方程1得出方程2的。
在Cormen等人关于算法简介的书中提到:
实际的最短路径权重delta(i, j)是多少?如果图不包含负权环,则所有最短路径都是简单的,因此最多包含 n - 1 条边。从顶点 i 到顶点 j 且具有超过 n - 1 条边的路径的权重不能小于从 i 到 j 的最短路径的权重。因此,实际的最短路径权重由下式给出:
delta(i,j) = d(i,j) power (n-1) = (i,j) power (n) = (i,j) power (n+1) ) = ...
问题 3:在上面的等式中,作者如何得到 n, n+1 条边,因为我们最多有 n-1 条边,以及上面的作业是如何工作的?
谢谢!
All,
I am reading about the relationship between all pairs shortest path and matrix multiplication.
Consider the multiplication of the weighted adjacency matrix with
itself - except, in this case, we replace the multiplication operation
in matrix multiplication by addition, and the addition operation by
minimization. Notice that the product of weighted adjacency matrix
with itself returns a matrix that contains shortest paths of length 2
between any pair of nodes.
It follows from this argument that A to power of n contains all shortest paths.
Question number 1:
My question is that in a graph we will be having at most n-1 edges between two nodes in a path, on what basis is the author discussing of path of length "n"?
Following slides
www.infosun.fim.uni-passau.de/br/lehrstuhl/.../Westerheide2.PPT
On slide 10 it is mentioned as below.
dij(1) = cij
dij(m) = min (dij(m-1), min1≤k≤n {dik(m-1) + ckj}) --> Eq 1
= min1≤k≤n {dik(m-1) + ckj} ------------------> Eq 2
Question 2: how author concluded Eq 2 from Eq 1.
In Cormen et al book on introduction to algorithms, it is mentioned as below:
What are the actual shortest-path weights delta(i, j)? If the graph contains no negative-weight cycles, then all shortest paths are simple and thus contain at most n - 1 edges. A path from vertex i to vertex j with more than n - 1 edges cannot have less weight than a shortest path from i to j. The actual shortest-path weights are therefore given by
delta(i,j) = d(i,j) power (n-1) = (i,j) power (n) = (i,j) power (n+1) = ...
Question 3: in above equation how author came with n, n+1 edges as we have at most n-1, and also how above assignment works?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
n 与 n-1 只是一个不幸的变量名称选择。他应该使用不同的字母来更清楚。
方程 2 并非直接来自方程 1。方程 2 只是第一个方程的第二项。我认为这是一个格式或复制粘贴错误(我无法检查 - 您的 ppt 链接已损坏)
作者只是明确指出,向路径:
这只是为了让您可以安全地在 (n-1) 处停止计算,并确保您拥有所有长度的所有路径中的最小路径。 (这很明显,但教科书在这里严格要求是有道理的......)
The n vs n-1 is just an unfortunate variable name choice. He should have used a different letter instead to be more clear.
Eq 2 does not directly come from Eq1. Eq 2 is just the second term from the first equation. I presume this is a formatting or copy-paste error (I can't check - your ppt link is broken)
The author is just explicitly pointing out that you have nothing to gain by adding more then n-1 edges to the path:
This is just so that you can safely stop your computations at (n-1) and be sure that you have the minimum paths among all paths of all lengths. (This is kind of obvious but the textbook has a point in being strict here...)
您混淆了正在讨论的多种度量:
该图可能有数百个顶点,但邻接矩阵 A^3 显示长度为 3 的最短路径。不同的 n 度量。
You're confusing the multiple measures being discussed:
The graph could have hundreds of vertices but your adjacency matrix A^3 shows the shortest paths of length 3. Different n measures.