notesonly.in

One notebook for every subject — open it anywhere.

Log in

Graph algorithms: Dijkstra, Bellman-Ford, MST (Kruskal, Prim)

Design and Analysis of Algorithms · Engineering

Study notes

Dijkstra from A: distances inf; A=0. Relax neighbors: B=4, C=2. Pick C (smallest unvisited): relax, D=2+1=3. Pick D: relax, B stays 4 (4 < 3+5). Pick B: done. Shortest paths: A->C=2, A->D=3, A->B=4. One negative edge would break this greedy logic.

← Back to topics for Engineering