public static Vertex at(Graph g, int x, int y) {

        DynamicArray<Vertex> vertices = g.getVertices();
        Vertex v = vertices.get(0);
        Vertex closestVertex = v;
        double closest = Integer.MAX_VALUE;
        for (int i = 0; i < vertices.getSize(); i++) {
            v = vertices.get(i);
            double thisX = v.getX();
            double thisY = v.getY();
            if (Math.sqrt(Math.pow(Math.abs(thisX - x), 2) + Math.pow(Math.abs(thisY - y), 2)) < closest) {
                closest = Math.sqrt(Math.pow(Math.abs(thisX - x), 2) + Math.pow(Math.abs(thisY - y), 2));
                closestVertex = v;
            }
        }
        if (closest < thresholdValue) {
            return closestVertex;
        } else {
            return null;
        }
    }