Write a pseudo code for a Graph algorithm
Yes, you can use the topological sort. Suppose topological sorting of the vertices gives you the sequence: $v_{1}, \dotsc, v_{n}$ such that there is no edge of the form $(v_{j},v_{i})$ for any $i &lt; j$.
Following would be the pseudocode to compute the minimum reachable $f(u)$ value for each vertex $v_{i} \in V$:
fun()
----- int min_val_reachable[n];    // array that stores minimum reachable f(u) value for each vertex

----- for(i = n to 1; i--)
-------- min_val_reachable[i] = f(v_i) // since a vertex v_i is reachable to itself
-------- for each vertex 'u' in adj_list[v_i]
-------------- if (min_val_reachable[i] &gt; min_val_reachable[u])
-------------------min_val_reachable[i] = min_val_reachable[u]
-------------- end
--------- end
----- end
----- return min_val_reachable[];

The time complexity of the topological sort is $O(|V| + |E|)$, and the time complexity of the above procedure is also $O(|V| + |E|)$. Thus, the overall complexity is $O(|V| + |E|)$.

You can prove the correctness of the above procedure using the induction technique as follows:
Hypothesis: After $t$ iterations of the outer &quot;for loop&quot;, we get the correct min_value_reachable[] for every vertex from $v_{n}$ to $v_{n-t+1}$
Base Case: For $t = 1$, it is easy to see that min_value_reachable[$v_n$] = $f(v_n)$ since $v_{n}$ does not has any child, and $v_{n}$ is reachable to itself.
The induction case is also simple. Hope you can figure out the details yourself.