DSAHardGraphs
Dijkstra's Shortest Path
đ Problem
Given a weighted graph and a source node, find the shortest distance from the source to every other node.
đ§ Approach
Maintain a 'distance' array initialized to infinity (except the source, which is 0). Repeatedly pick the unvisited node with the smallest known distance, mark it visited, then 'relax' its neighbors â if going through this node gives a shorter path to a neighbor, update the neighbor's distance. A min-priority-queue makes picking the smallest efficient.