- Find all the [strongly connected components][1] (SCC) of the original
   graph.
 - Replace each SCC by a single node - the resulting graph $G'$ will be *acyclic*.
 - Find all the *sources* and *sinks* in $G'$ - let $m$ will be a number of sources, and $n$ - a number of sinks.
 - Add $max(m,n)$ edges from sinks to sources in $G'$.
 - Replace each node, representing SCC, by this SCC.


  [1]: https://en.wikipedia.org/wiki/Strongly_connected_component