Dijkstra's algorithm with negative weights

后端 未结 7 1441
有刺的猬
有刺的猬 2020-11-30 01:06

Can we use Dijkstra\'s algorithm with negative weights?

STOP! Before you think \"lol nub you can just endlessly hop between two points and get an in

7条回答
  •  日久生厌
    2020-11-30 01:52

    Yes, you could do that with adding one step at the end i.e.

                If v ∈ Q, Then Decrease-Key(Q, v, v.d)
                Else Insert(Q, v) and S = S \ {v}.
    

提交回复
热议问题