DAGImpl implements DAG<V> { @Override public boolean addVertex(final V v) { if (!adjacent.containsKey(v)) { adjacent.put(v, new HashSet<>()); inDegrees.put(v, 0); rootVertices.add(v); numVertices++; return true; } else { LOG.log(Level.WARNING, "The vertex {0} already exists", v); return false; } }  @Override Set<V> getRootVertices(); @Override boolean isAdjacent(final V v, final V w); @Override Set<V> getNeighbors(final V v); @Override boolean addVertex(final V v); @Override boolean removeVertex(final V v); @Override boolean addEdge(final V v, final V w); @Override boolean removeEdge(final V v, final V w); @Override int getInDegree(final V v); @Override int getNumVertices(); @Override String toString(); @Override String toJSON();  }
@Test public void addVertexTest() { final List<Integer> expected = ImmutableList.of(1, 2, 3, 4); final DAG<Integer> dag = new DAGImpl<>(); dag.addVertex(1); dag.addVertex(2); dag.addVertex(3); dag.addVertex(4); assertEquals(new HashSet<>(expected), dag.getRootVertices()); }