UndirectedGraphImpl implements UndirectedGraph<V, E> { @Override public V removeVertex(int v) { checkVertex(v); for (Edge<E> e : edges) { if (e != null && (e.getV1() == v || e.getV2() == v)) { throw new PowsyblException("An edge is connected to vertex " + v); } } V obj = vertices.get(v).getObject(); if (v == vertices.size() - 1) { vertices.remove(v); cleanVertices(v - 1); } else { vertices.set(v, null); availableVertices.add(v); } invalidateAdjacencyList(); notifyListener(); return obj; }  @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 testRemoveVertex() { graph.addVertex(); graph.addVertex(); graph.addVertex(); int e1 = graph.addEdge(0, 1, null); int e2 = graph.addEdge(1, 2, null); graph.removeEdge(e1); graph.removeVertex(0); }