Concept Flow - Shortest Path in DAG Using Topological Order
Build graph with edges and weights
Find topological order
Initialize distances array with Infinity
Set distance to source as 0
For each node in topological order
Relax edges from current node
Update distances if shorter path found
Repeat until all nodes processed
Distances array holds shortest paths from source
We first build the graph, find a topological order, then relax edges in that order to find shortest paths.
