public void setNumVertices(int numVertices)
    {
        if (numVertices > myEdges.length) {
            throw new IllegalArgumentException("Max vertex for this graph is " + myEdges.length
                                               + ", can't hold " + numVertices + " vertices.");
        }
        // Remove edges out of the removed nodes.
        for (int ii = numVertices; ii < myNumVertices; ii++) {
            while (myEdges[ii].size() > 0) {
                myEdges[ii].pop();
            }
        }
        // Remove edges going to the removed nodes.
        for (int ii = 0; ii < numVertices; ii++) {
            Iterator<Edge> itr = myEdges[ii].iterator();
            while (itr.hasNext()) {
                if (itr.next().getTarget() >= numVertices) {
                    itr.remove();
                }
            }
        }
        myNumVertices = numVertices;
    }