Graph Theory37 sections · 1633 units
Open in Course

Lessons Learned

summary

You learned how to model counting nodes as a longest path problem with uniform edge weights. Define dp[u] as the count, and update with dp[u] + 1. You practiced path reconstruction using a parent array. Store the predecessor whenever you update dp[v], then backtrack from the destination.

You handled unreachable nodes by initializing dp[u] = -Infinity and checking if dp[destination] is still -\infty after processing.