Блог пользователя Equilibrium

Автор Equilibrium, 10 лет назад, По-английски

Hey , I have a question about BellmanFord algorithm . As i have seen in pseudocodes they say for a u-v edge , we check if we can shorter the distance or not (if(Distance[u]+Weight[u-v]<Distance[v] then Distance[v]=Distance[u]+Weight[u-v]) but my question is when edges are bidirectional are we supposed to check for the other endpoint or one is enough ?

Thanks.

  • Проголосовать: нравится
  • -1
  • Проголосовать: не нравится

»
10 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

I think it's enough to only check if (weight [u-v]> abs(distance (v)-distance (u)) is true or false If it was true there will be no need to update distance (v) or distance (u) But if it was false you need to update your distances