dijkstra algorithm Why not have negative side?

Because the Dijkstra algorithm in calculating the shortest path , the negative side will not be updated as the path length it has been calculated vertex (included too), and

Thus, in a negative side of FIG., It may have some of the vertices finally calculated path length is not the shortest.

Suppose the first two digits represent the vertex, the third number represents the edge weights or path length,

Consider three vertices, three sides: (1,2,1), (1,3,2), (3, -3), the final computed path length (1,2,1), (1 , 3, -2), but evident (1,2, -1) this shorter path.

 

Guess you like

Origin www.cnblogs.com/FengZeng666/p/11245243.html