Bellman Ford and One Olympiad Questions?

时光怂恿深爱的人放手 提交于 2020-12-29 09:11:58

问题


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

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

d(v)>d(u)+w(u,v)

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?

  1. number of edges in all shortest paths from s is at most k-1
  1. weight of all shortest paths from s is at most k-1
  1. Graph has no negative cycle.

Who can discuss on these options ?


回答1:


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




回答2:


i think option 3 is incorrect because to know if there is negative weight cycle ,the Bellman ford algorithm needs to run n times. first n-1 times to calculate the shortest path and then one more time to check if there is any improvement in the distances if there are improvements ,it means there is a negative weight cycle.



来源:https://stackoverflow.com/questions/29520550/bellman-ford-and-one-olympiad-questions

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!