@Test public void testAddEdge() { clearAndTest(); assertFalse(graph.addEdge(1, 2, "attr1")); graph.addVertex(1, "v1"); assertFalse(graph.addEdge(1, 2, "attr1")); graph.addVertex(2, "v2"); assertFalse(graph.addEdge(1, 1, "wrong")); assertTrue(graph.addEdge(1, 2, "attr_12")); assertFalse(graph.containsEdge(1, 3)); assertTrue(graph.containsEdge(1, 2)); assertEquals(graph.getEdgeNumber(), 1); assertEquals(graph.getEdge(1, 2), "attr_12"); assertEquals(graph.getEdges().size(), 1); assertTrue(graph.getEdges().containsKey(1)); graph.addVertex(3, "v3"); graph.addVertex(4, "v4"); assertTrue(graph.addEdge(3, 4, "attr_34")); assertTrue(graph.addEdge(1, 4, "attr_14")); assertTrue(graph.containsEdge(3, 4)); assertTrue(graph.containsEdge(1, 4)); assertEquals(graph.getEdgeNumber(), 3); assertEquals(graph.getEdge(3, 4), "attr_34"); assertEquals(graph.getEdge(1, 4), "attr_14"); assertEquals(graph.getEdges().size(), 2); assertTrue(graph.getEdges().containsKey(1)); assertTrue(graph.getEdges().containsKey(3)); assertEquals(graph.getEdges().get(1).size(), 2); assertEquals(graph.getEdges().get(3).size(), 1); clearAndTest(); assertTrue(graph.addEdge(1, 2, "attr1", true)); assertTrue(graph.addEdge(1, 3, "attr2", true)); assertFalse(graph.addEdge(1, 4, "attr2", false)); assertEquals(graph.getVertexNumber(), 3); assertEquals(graph.getEdgeNumber(), 2); assertTrue(graph.containsEdge(1, 2)); assertTrue(graph.containsEdge(1, 3)); assertTrue(graph.containsVertex(1)); assertTrue(graph.containsVertex(2)); assertTrue(graph.containsVertex(3)); }
public boolean addEdge(VK start, VK end) { return addEdge(start, end, false); }
Graph { public boolean addEdge(VK start, VK end) { return addEdge(start, end, false); } }
Graph { public boolean addEdge(VK start, VK end) { return addEdge(start, end, false); } Graph(); }
Graph { public boolean addEdge(VK start, VK end) { return addEdge(start, end, false); } Graph(); synchronized void addVertex(VK key, VD vertex); synchronized void addVertexIfAbsent(VK key, VD vertex); synchronized void removeVertex(VK key); boolean addEdge(VK start, VK end); boolean addEdge(VK start, VK end, boolean createVertex); boolean addEdge(VK start, VK end, ED edge); synchronized boolean addEdge(VK start, VK end, ED edge, boolean createVertex); synchronized void removeEdge(VK start, VK end); boolean forceRefreshPreEdges(Collection<VK> addStartKeys,
                                      VK endKey); synchronized boolean forceRefreshPreEdges(Collection<VK> addStartKeys,
                                                   VK endKey,
                                                   boolean createVertex); boolean addRemoveMultiEdges(Collection<VK> removeStartKeys,
                                     Collection<VK> addStartKeys,
                                     VK endKey); synchronized boolean addRemoveMultiEdges(Collection<VK> removeStartKeys,
                                                  Collection<VK> addStartKeys,
                                                  VK endKey,
                                                  boolean createVertex); synchronized void clear(); synchronized boolean containsVertex(VK key); synchronized VD getVertex(VK key); Map<VK, VD> getVertices(); synchronized boolean containsEdge(VK startKey, VK endKey); Map<VK, Map<VK, ED>> getEdges(); synchronized ED getEdge(VK startKey, VK endKey); synchronized int getEdgeNumber(); int getVertexNumber(); synchronized Collection<VK> getStartVertex(); synchronized Collection<VK> getEndVertex(); Set<VK> getPreNode(VK key); Map<VK, ED> getPreNodeAttr(VK key); Set<VK> getPostNode(VK key); Map<VK, ED> getPostNodeAttr(VK key); synchronized int getIndegree(VK key); synchronized int getOutdegree(VK key); boolean hasCycle(); List<VK> broadFirstSearch(); List<VK> depthFirstSearch(); List<VK> topologicalSort(); synchronized boolean isConnected(); }
Graph { public boolean addEdge(VK start, VK end) { return addEdge(start, end, false); } Graph(); synchronized void addVertex(VK key, VD vertex); synchronized void addVertexIfAbsent(VK key, VD vertex); synchronized void removeVertex(VK key); boolean addEdge(VK start, VK end); boolean addEdge(VK start, VK end, boolean createVertex); boolean addEdge(VK start, VK end, ED edge); synchronized boolean addEdge(VK start, VK end, ED edge, boolean createVertex); synchronized void removeEdge(VK start, VK end); boolean forceRefreshPreEdges(Collection<VK> addStartKeys,
                                      VK endKey); synchronized boolean forceRefreshPreEdges(Collection<VK> addStartKeys,
                                                   VK endKey,
                                                   boolean createVertex); boolean addRemoveMultiEdges(Collection<VK> removeStartKeys,
                                     Collection<VK> addStartKeys,
                                     VK endKey); synchronized boolean addRemoveMultiEdges(Collection<VK> removeStartKeys,
                                                  Collection<VK> addStartKeys,
                                                  VK endKey,
                                                  boolean createVertex); synchronized void clear(); synchronized boolean containsVertex(VK key); synchronized VD getVertex(VK key); Map<VK, VD> getVertices(); synchronized boolean containsEdge(VK startKey, VK endKey); Map<VK, Map<VK, ED>> getEdges(); synchronized ED getEdge(VK startKey, VK endKey); synchronized int getEdgeNumber(); int getVertexNumber(); synchronized Collection<VK> getStartVertex(); synchronized Collection<VK> getEndVertex(); Set<VK> getPreNode(VK key); Map<VK, ED> getPreNodeAttr(VK key); Set<VK> getPostNode(VK key); Map<VK, ED> getPostNodeAttr(VK key); synchronized int getIndegree(VK key); synchronized int getOutdegree(VK key); boolean hasCycle(); List<VK> broadFirstSearch(); List<VK> depthFirstSearch(); List<VK> topologicalSort(); synchronized boolean isConnected();  }