Uses recursive DFS with a per-path visited set to handle shared nodes (e.g. a node reachable via multiple routes). Enumerates every path — suitable for small graphs; exponential for large ones.
Must-visit nodes — paths must pass through ALL
Topologically sorts the DAG, then computes dp[node] = Σ dp[children] (with dp[end]=1) in O(V+E). For must-visit filters, all orderings of waypoints are tried; only topologically consistent orderings contribute. Path count is the product of segment counts — no enumeration needed.