这是Dijkstra伪代码:
Dijkstra(G,s) {
foreach vεV do { d[v] = infinity }
Queue priority initialization Q with n elements
Q = V
d[s] = 0
while(Q is not empty) {
v = ExtractMin(Q)
foreach e = (v,w) ε E do
if d(w) > d(v) + l {
d(w) = d(v) + l //reduce priority
ChangeKey(Q,w,d[w]) //reduce key
}
}
}
如何修改此算法以找到在所有最短路径中边数最小的最短路径。