Concept Flow - Shortest Path in DAG Using Topological Order
Build graph with edges and weights
Find topological order of nodes
Initialize distances: source=0, others=∞
For each node in topological order
Relax edges from current node
Update distances if shorter path found
Repeat until all nodes processed
Final shortest distances from source
We first order nodes so all edges go forward. Then we update shortest distances step-by-step following this order.
