贝尔曼·福特(Bellman Ford)和一届奥林匹克竞赛?

编程入门 行业动态 更新时间:2024-10-21 20:33:42
本文介绍了贝尔曼·福特(Bellman Ford)和一届奥林匹克竞赛?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

三天前,我参加了一次奥林匹克考试.我遇到了一个很好的问题,如下.

I took an Olympiad Exam three days ago. I ran into a nice question as follows.

我们知道bellman-ford算法会检查每个步骤中的所有边缘,如果存在,则会检查每个边缘,

We know the bellman-ford algorithm checks all edges in each step, and for each edge if,

然后更新 d(v),以使 w(u,v)是边缘(u,v)的权重,并且 d(u)是顶点 u 的最佳查找路径的长度.如果第一步中我们没有不更新顶点,则算法终止.假设该算法用于从图G中具有 n 个顶点且在 k<之后的顶点的所有 s 路径中找到所有最短路径.n 次迭代已完成,以下哪一项是正确的?

then d(v) being updated such that w(u,v) is the weight of edge (u, v) and d(u) is the length of best finding path for vertex u. if in one step we have no update for vertexes, the algorithms terminates. Supposing this algorithm for finding all shortest path from vertex s in graph G with n vertex after k < n iterations is finished, which of the following is correct?

  • 距 s 的所有最短路径中的边数最多为 k-1
  • number of edges in all shortest paths from s is at most k-1
  • 来自 s 的所有最短路径的权重最多为 k-1
  • weight of all shortest paths from s is at most k-1
  • 图形没有负循环.
  • 谁可以讨论这些选项?

    推荐答案

    1不正确.首先,我们总是找到具有k条边的最短路径(如果有的话).而且,如果我们碰巧以最短路径树的拓扑顺序放宽弧线,那么尽管最短路径树可能任意深,我们还是会进行一次迭代收敛.

    1 is incorrect. First of all, we always find shortest paths with k edges, if any. But also, if we happen to relax the arcs in the topological order of a shortest path tree, then we converge in one iteration, despite the fact that the shortest path tree may be arbitrarily deep.

    s --> t --> u --> v Relax s->t, t->u, u->v; shortest path from s->v is three hops, but B--F has made two iterations.

    2是不正确的,因为谁知道权重是什么?

    2 is incorrect, because who knows what the weights are?

    100 s --> t Relax s->t; weight is 100, but B--F has made two iterations.

    3是正确的,因为根据平均参数,至少一个负周期的弧不会松弛.假设 v1,...,vn 为一个循环.由于弧线是松弛的,因此我们有 d(vi)+ len(vi-> vi + 1)-d(vi + 1)> = 0 .对所有 i 的不等式求和,并望远镜化 d 项,以简化为 sum_i len(vi-> vi + 1)> = 0 ,表示周期是非负的.

    3 is correct, because by an averaging argument at least one arc of a negative cycle would be unrelaxed. Let v1, ..., vn be a cycle. Since the arcs are relaxed, we have d(vi) + len(vi->vi+1) - d(vi+1) >= 0. Sum the inequalities for all i and telescope the d terms to simplify to sum_i len(vi->vi+1) >= 0, which says that the cycle is nonnegative.

    更多推荐

    贝尔曼·福特(Bellman Ford)和一届奥林匹克竞赛?

    本文发布于:2023-11-30 20:56:37,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1651446.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:贝尔   奥林匹克   福特   一届   Bellman

    发布评论

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

    >www.elefans.com

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