If the graph contains cycles (there is no topological sort), then two tricks can help:
1) Calculate the dynamics n times, where n is the number of vertices in the graph (by analogy with the Ford-Bellman algorithm). But this increases the asymptotics and is rarely efficient in general.
2) Construct graph condensation. For each strongly connected component of the original graph, solve the problem separately. The condensed graph is acyclic and for it you can use the standard approach with topological sorting, while using as vertex values, the calculated values for the strongly connected components. This method is mainly used.