所有配对最短路径与动态规划

发布于 2024-12-19 11:37:49 字数 1006 浏览 1 评论 0原文

所有,

我正在阅读所有对最短路径和矩阵乘法之间的关系。

考虑加权邻接矩阵与 本身 - 除了在这种情况下,我们替换乘法运算 在矩阵乘法和加法中,以及加法运算 最小化。请注意,加权邻接矩阵的乘积 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

狂之美人 2024-12-26 11:37:49
  1. n 与 n-1 只是一个不幸的变量名称选择。他应该使用不同的字母来更清楚。

    A^1 的最短路径长度可达 1(简单地说)
    A^2 的最短路径长度可达 2
    A^k 具有长度可达 k 的最短路径
    
  2. 方程 2 并非直接来自方程 1。方程 2 只是第一个方程的第二项。我认为这是一个格式或复制粘贴错误(我无法检查 - 您的 ppt 链接已损坏)

  3. 作者只是明确指出,向路径:

    A^(n-1), //长度为tp(n-1)的最短路径
    等于A^n //长度为tp(n)的最短路径
    等于A^(n+1) //长度为tp(n+1)的最短路径
    ...
    

    这只是为了让您可以安全地在 (n-1) 处停止计算,并确保您拥有所有长度的所有路径中的最小路径。 (这很明显,但教科书在这里严格要求是有道理的......)

  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.

    A^1 has the shortest paths of length up to 1 (trivially)
    A^2 has the shortest paths of length up to 2
    A^k has the shortest paths of length up to k
    
  2. 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)

  3. The author is just explicitly pointing out that you have nothing to gain by adding more then n-1 edges to the path:

    A^(n-1),            //the shortest paths of length up tp (n-1)
    is equal to A^n     //the shortest paths of length up tp (n)
    is equal to A^(n+1) //the shortest paths of length up tp (n+1)
    ...
    

    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...)

不打扰别人 2024-12-26 11:37:49

在图中,路径中的两个节点之间最多有 n-1 条边,作者在什么基础上讨论长度为“n”的路径?

您混淆了正在讨论的多种度量:

  • A^n 表示顶点之间长度n 的“最短路径”(按权重)。
  • “两个节点之间最多有 n-1 条边”——我认为在这种情况下,您将 n 视为图形的大小。

该图可能有数百个顶点,但邻接矩阵 A^3 显示长度为 3 的最短路径。不同的 n 度量。

In a graph we will be having atmost n-1 edges between two nodes in a path, on what basis author is discussing of path of length "n"?

You're confusing the multiple measures being discussed:

  • A^n represents the "shortest paths" (by weight) of length n between vertices.
  • "at most n-1 edges between two nodes" -- I presume in this case you're thinking of n as the size of the graph.

The graph could have hundreds of vertices but your adjacency matrix A^3 shows the shortest paths of length 3. Different n measures.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文