@SuppressWarnings("unchecked")
    public Graph(int numVertices, boolean allowMultipleEdges, VertexFactory<V> vertexFactory) {
        if (numVertices <= 0)
            throw new IllegalArgumentException();
        this.allowMultipleEdges = allowMultipleEdges;