class GraphMatrix { // simple graph (no multiple edges); undirected; unweighted private int numVertices; private int numEdges; private boolean[][] adjMatrix; public GraphMatrix(int n) { numVertices = n; numEdges = 0; adjMatrix = new boolean[n][n]; } // end constructor public int getNumVertices() { return numVertices; } // end getNumVertices public int getNumEdges() { return numEdges; } // end getNumEdges public boolean isEdge(int v, int w) { return adjMatrix[v][w]; } // end getWeight public void addEdge(int v, int w) { if (!isEdge(v,w)) { adjMatrix[v][w] = true; adjMatrix[w][v] = true; numEdges++; } } // end addEdge public void removeEdge(int v, int w) { if (isEdge(v,w)) { adjMatrix[v][w] = false; adjMatrix[w][v] = false; numEdges--; } } // end remove public int nextAdjacent(int v,int w) // if w<0, return the first adjacent vertex // otherwise, return next one after w // if none exist, return -1 { for (int i=w+1; i