Concept Flow - Shortest Path in DAG Using Topological Order
Build graph with edges and weights
Find topological order of nodes
Initialize distances: start node=0, others=∞
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 start
We first build the graph and find a topological order. Then we initialize distances and relax edges in that order to find shortest paths.
