0

Here is Dijkstra pseudocode:

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
        }
    }
}

How can i modify this algorithm to find the shortest path that also has the smallest number of edges among all shortest paths.

amit
  • 175,853
  • 27
  • 231
  • 333
Lee Yaan
  • 547
  • 7
  • 26

0 Answers0