title: How to find roots and leaves set in jgrapht DirectedAcyclicGraph
body: <p>My code:</p>
  
  <pre><code>import org.jgrapht.graph.DirectedAcyclicGraph;
  // ...
  private DirectedAcyclicGraph&lt;String, DefaultEdge&gt; graph = new DirectedAcyclicGraph&lt;&gt;(DefaultEdge.class);
  // ...
  graph.addVertex("x");
  graph.addVertex("y");
  // ...
  graph.addEdge("x", "y");
  </code></pre>
  
  <p>After constructing the graph, how can I get a set of all the roots (vertices with no incoming edges) and of all leaves (vertices with no outgoing edges)</p>