Longest paths in a DAG

Find the highest score you can earn on the way from the start to each level. Each arrow gives the points for that move. The arrows never take you back to a level you have passed.

Arrange the levels so every move goes forwards. At the next level, keep the best score of all the routes that reach it. A loop makes this ordering impossible.

Time is O(V + E). Infinity marks unreachable vertices.