UndirectedGraphImpl implements UndirectedGraph<V, E> { @Override public int addEdge(int v1, int v2, E obj) { checkVertex(v1); checkVertex(v2); int e; Edge<E> edge = new Edge<>(v1, v2, obj); if (removedEdges.isEmpty()) { e = edges.size(); edges.add(edge); } else { e = removedEdges.removeAt(0); edges.set(e, edge); } invalidateAdjacencyList(); notifyListener(); return e; }  @Override int addVertex(); @Override void addVertexIfNotPresent(int v); @Override boolean vertexExists(int v); @Override V removeVertex(int v); @Override int getVertexCount(); @Override void removeAllVertices(); @Override int addEdge(int v1, int v2, E obj); @Override E removeEdge(int e); @Override void removeAllEdges(); @Override int getEdgeCount(); @Override int[] getVertices(); @Override int[] getEdges(); @Override int getVertexCapacity(); @Override Iterable<V> getVerticesObj(); @Override Stream<V> getVertexObjectStream(); @Override V getVertexObject(int v); @Override void setVertexObject(int v, V obj); @Override int getEdgeVertex1(int e); @Override int getEdgeVertex2(int e); @Override Iterable<E> getEdgesObject(); @Override Stream<E> getEdgeObjectStream(); @Override E getEdgeObject(int e); @Override List<E> getEdgeObjects(int v1, int v2); @Override void traverse(int v, Traverser traverser, boolean[] encountered); @Override void traverse(int v, Traverser traverser); @Override List<TIntArrayList> findAllPaths(int from, Function<V, Boolean> pathComplete, Function<E, Boolean> pathCancelled); @Override void addListener(UndirectedGraphListener l); @Override void removeListener(UndirectedGraphListener l); @Override void print(PrintStream out, Function<V, String> vertexToString, Function<E, String> edgeToString);  }
@Test public void testAddEdge() { graph.addVertex(); graph.addVertex(); int e = graph.addEdge(0, 1, null); assertEquals(2, graph.getVertexCount()); assertEquals(0, e); assertEquals(1, graph.getEdgeCount()); assertEquals(0, graph.getEdgeVertex1(e)); assertEquals(1, graph.getEdgeVertex2(e)); }