Comments

dp[u]=(# of back-edges going up from u)−(# of back-edges going down from u)+∑dp[v] v is a child of u.

i still dont understand this formula, why are we subtracting number of back edges going down from u ?