Graph Algorithms

Answer & solution
Answer: D (no official key was published)
Step through it (22 steps)
1. All vertices receive the correct distance despite the negative edges. From a, settle b at 1, which sets c=3 and e=−2. Settle e at −2, then f at 0, setting g=3. Vertices c and g tie at 3.
2. Whichever is handled first, c sets h=3−5=−2 before h is settled (if g was handled first it only proposes h=5). Vertex h proposes e=−1, not an improvement over −2. Vertex d gets 6 from c and offers no improvement to a or g. Final distances (a,b,c,d,e,f,g,h)=(0,1,3,6,−2,0,3,−2).
3. They also satisfy every edge relaxation inequality, with each value attained by a path, proving optimality. Negative edges invalidate Dijkstra’s general guarantee, but do not force failure on every particular input.