В руководстве автостопщика по алгоритмам обсуждаются следующие указатели:
1.6 Counting or Optimizing Good Paths
In an n × m grid, we want to go from the left bottom corner to the upper right corner. Each
time we can only take a step to the right, or a step up. The number of ways we can do this
is exactly (n+m)!/(n! * m!). But what if we forbid some points on the grid? For example, if we
forbid all the points above the line y = x. Some of the problems has answer in closed formula.
But all of them can be solved quickly by dynamic programming.
Problem 1.6 Given a directed acyclic graph, how many paths are there from u to v? What is the longest one if there are weights on the edges?
Мой вопрос: как связаны эти две проблемы? Какая связь между сеткой здесь и DAG. В самом stackoverflow я прочитал, что если мы движемся только в двух направлениях в сетке, мы можем предположить, что это DAG. Вопрос может показаться очень наивным, но я новичок, и любая помощь будет очень признательна.