public void removeEdge(int v, int w) throws IllegalArgumentException { if (v < 0 || v >= numVertices || w < 0 || w >= numVertices) { throw new IllegalArgumentException( "Out of range: v = " + v + ", w = " + w + "."); } if (adjacentVertices[v].contains(w) || adjacentVertices[w].contains(v)) { adjacentVertices[v].remove(w); adjacentVertices[w].remove(v); edgeCosts.remove(new Edge(v,w)); numEdges--; } }