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 = infinity
For each node in topological order
Relax edges from current node
Update distances if shorter path found
Repeat until all nodes processed
Result: shortest distances from start to all nodes
We first build the graph and find a topological order. Then we initialize distances and relax edges in that order to find shortest paths.
