title: Finding all the roots in a directed graph
body: <p>I need to find an algorithm for finding all the roots in a directed graph, in O(n+m).</p>
  
  <p>I have an algorithm for finding a single root:</p>
  
  <ol>
  <li>Run DFS(v) on some v in V. If the result is a single spanning tree, then v is a root. Otherwise, the result is a forest of trees. Then:</li>
  <li>Run DFS(u) on the root of the last tree. If the result is a single spanning tree, then u is a root. Else, there are no roots in the graph.</li>
  </ol>
  
  <p>Now if I want to find all the roots, is the best way to just run the above algorithm O(n) times, on a different vertex in the last tree every time ? Assuming I found a root, if another root exists then it must be on the last tree, then is it O(n+m) if I continue to run the above algorithm until receiving "no root exists" or until going over all vertices ?</p>
  
  <p>Thanks in advance !</p>