Let $G = (V, E)$ be a directed acyclic graph, which is quite sparse (in the examples I have in mind, $|E| \approx 10|V|$ or so). For each vertex $v \in V$, let $f(v)$ be the number of vertices reachable from $v$. Is there a way of calculating the function $f$ for all vertices in time $|V| + |E|$?
The obvious algorithm is to do a reachability check (using say, depth-first-search) from every vertex, giving a running time of $|V|(|V| + |E|)$, but I am finding this too slow on the particularly large graphs I have at hand.