The Hitchhiker's guide to Algorithms discusses the following pointers:

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?

My question is how are the two problems related? What is the relation between the grid here and a DAG. On stackoverflow itself I read that if we're moving in only two directions in the grid then we can assume it's a DAG. The question may sound very naive, but I'm a beginner and any help will be much appreciated.

1 Answer
1

Every point in the grid is a vertex. You have m * n vertices.
There is an edge going from each vertex to the vertex representing the point on its left and from each vertex to vertex representing the point on its top.

[Sample] (google.com/…) If you look for "small world graph" is this how a graph would look like if each pt of intersection on the grid is a node and nodes have more than 2 neighbors? [I want to extend it graph with left and top neighbors to graph with >2 neighbors]
–
user1071840Oct 16 '12 at 22:39

I don't know if I understand your question, but in that graph every intersection is a node, and there's an edge between each node and the top, the left, the right and the bottom points. The point is that you want to restrict the movement in the graph to only right and top, that's why I said you only use those edges.
–
leoOct 16 '12 at 22:43

I understood your answer. I just wanted to expand it, sorry for not making it clear.
–
user1071840Oct 16 '12 at 22:50