code: public static <V> Set<V> getLeafVertices(DirectedGraph<V, DefaultEdge> graph) {
          Set<V> vertexSet = graph.vertexSet();
          Set<V> leaves = new HashSet<V>(vertexSet.size()*2);
          for (V vertex : vertexSet) {
              if (graph.outgoingEdgesOf(vertex).isEmpty()) {
                  leaves.add(vertex);
              }
          }
          return leaves;
      }
docs: Find the leave vertices in the graph. I.E. Vertices that have no outgoing edges
  @param graph graph to search
  @return mutable snapshot of all leaf vertices.