We did some examples of counting the number of distinct paths from a given vertex S to a given vertex T in a DAG. Then we discussed a general algorithm based on the following recurrence: Define N(V) = the number of distinct paths from S to V. Then N() satisfies the following recurrence relation: : N(S) = 1 and : N(V) = ∑W : (W,U) ∈ E N(W). We discussed a linear-time algorithm for computing the number of distinct S->T paths in a DAG using this recurrence. Then we tried to convince ourselves that the recurrence was true. |
|