@Test public void addVertexTest() { final List<Integer> expected = ImmutableList.of(1, 2, 3, 4); final DAG<Integer, Direction> dag = new AdjacentListConcurrentMapDAG<>(); dag.addVertex(1); dag.addVertex(2); dag.addVertex(3); dag.addVertex(4); Assert.assertEquals(new HashSet<>(expected), dag.getRootVertices()); }
@Override public boolean addVertex(final V v) { if (!adjacent.containsKey(v)) { adjacent.put(v, new ConcurrentHashMap<V, I>()); inDegrees.put(v, 0); numVertices += 1; return true; } else { LOG.log(Level.WARNING, "The vertex {0} already exists", new Object[]{v}); return false; } }
AdjacentListConcurrentMapDAG implements DAG<V, I> { @Override public boolean addVertex(final V v) { if (!adjacent.containsKey(v)) { adjacent.put(v, new ConcurrentHashMap<V, I>()); inDegrees.put(v, 0); numVertices += 1; return true; } else { LOG.log(Level.WARNING, "The vertex {0} already exists", new Object[]{v}); return false; } } }
AdjacentListConcurrentMapDAG implements DAG<V, I> { @Override public boolean addVertex(final V v) { if (!adjacent.containsKey(v)) { adjacent.put(v, new ConcurrentHashMap<V, I>()); inDegrees.put(v, 0); numVertices += 1; return true; } else { LOG.log(Level.WARNING, "The vertex {0} already exists", new Object[]{v}); return false; } } AdjacentListConcurrentMapDAG(); }
AdjacentListConcurrentMapDAG implements DAG<V, I> { @Override public boolean addVertex(final V v) { if (!adjacent.containsKey(v)) { adjacent.put(v, new ConcurrentHashMap<V, I>()); inDegrees.put(v, 0); numVertices += 1; return true; } else { LOG.log(Level.WARNING, "The vertex {0} already exists", new Object[]{v}); return false; } } AdjacentListConcurrentMapDAG(); @Override int numberOfVertices(); @Override int numberOfEdges(); @Override Set<V> getRootVertices(); @Override Collection<V> getVertices(); @Override boolean hasVertex(final V v); @Override boolean isAdjacent(final V v1, final V v2); @Override Map<V, I> getEdges(final V v); @Override boolean addVertex(final V v); @Override boolean removeVertex(final V v); @Override boolean addEdge(final V v1, final V v2, final I i); @Override boolean removeEdge(final V v1, final V v2); @Override int getInDegree(final V v); }
AdjacentListConcurrentMapDAG implements DAG<V, I> { @Override public boolean addVertex(final V v) { if (!adjacent.containsKey(v)) { adjacent.put(v, new ConcurrentHashMap<V, I>()); inDegrees.put(v, 0); numVertices += 1; return true; } else { LOG.log(Level.WARNING, "The vertex {0} already exists", new Object[]{v}); return false; } } AdjacentListConcurrentMapDAG(); @Override int numberOfVertices(); @Override int numberOfEdges(); @Override Set<V> getRootVertices(); @Override Collection<V> getVertices(); @Override boolean hasVertex(final V v); @Override boolean isAdjacent(final V v1, final V v2); @Override Map<V, I> getEdges(final V v); @Override boolean addVertex(final V v); @Override boolean removeVertex(final V v); @Override boolean addEdge(final V v1, final V v2, final I i); @Override boolean removeEdge(final V v1, final V v2); @Override int getInDegree(final V v);  }