为什么大多数图算法并不那么容易负数适应?并不、负数、算法、容易

2023-09-11 04:03:21 作者:从未拥有何谈失去

借助算法设计手册说:

大多数图形算法不那么容易负数适应。的确,最短路径算法有负数麻烦,而且肯定使用这种技术不会产生可能的最长的路径

Most graph algorithms do not adapt so easily to negative numbers. Indeed, shortest path algorithms have trouble with negative numbers, and certainly do not generate the longest possible path using this technique.

但是,为什么?当我们只需要添加一个负 - 原重量的面前,我想涉及最重图的问题同样可以处理,对

But why? When we just add a negative - in front of original weight, I think most graph problems involving weight can be dealt equally, right?

推荐答案

因为当你在考虑你总是最后考虑到所有的单步骤的总和路径的最小或最大的成本。

Because when you are considering the minimum or maximum cost of a path you always end up considering the sum of all single steps.

此外,由于通过选择由(步骤不同幅度的,当然)步最好的方法步骤,具有负的权重将只产生循环或误报。很多这样的算法在当地工作

And since many of these algorithms work locally by choosing best approach step by step (with step of different magnitude, of course), having negative weights would just generate cycles or false positives.

具有一负权意味着一个路径的成本可以在将来减少,这就是为什么它产生了问题:您甚至达到一个点,其中,路径到现在后不能排除潜在的良好的路径列表的路径比其他更昂贵,因为你可以找到与负权重的边缘而改变的情况

Having a negative weight implies that the cost of a path can decrease in the future, that's why it creates problems: you could not exclude paths from a list of potential good paths even after reaching a point in which the path up to now is more expensive than the other because you could find edges with negative weight which change the situation.

只是作为一个例子:如果你有两个节点(重量)的两个边缘相互连接 1 -2 你可以创建它们之间的周期,以确定与任意低成本的路径(甚至-∞)。

Just as an example: if you have two nodes connected mutually by two edges of weight 1 and -2 you could create a cycle between them to determine a path with arbitrary low cost (even -∞).

 
精彩推荐
图片推荐