public void createRandomGraph(int nrVertices) {

        clearGraph();

        int max_x = width - SQUARE_SIZE;
        int max_y = height - SQUARE_SIZE;
        int min_x = SQUARE_SIZE;
        int min_y = SQUARE_SIZE;

        Random rand = new Random();
        Set<Point> pts = new HashSet<Point>();

        while (pts.size() < nrVertices) {
            int rand_x = rand.nextInt((max_x - min_x) + 1) + min_x;
            int rand_y = rand.nextInt((max_y - min_y) + 1) + min_y;
            int x = rel(rand_x);
            int y = rel(rand_y);
            pts.add(new Point(x, y));
        }

        int index = 0;
        for (Point p : pts) {
            addVertex(p, String.valueOf(index++));
        }

        for (int i = 0; i < (pts.size() / 2); i++) {
            int rand_1 = rand.nextInt((index - 1) + 1);
            int rand_2 = rand.nextInt((index - 1) + 1);
            while (rand_1 == rand_2) {
                rand_2 = rand.nextInt((index - 1) + 1);
            }

            Vertex u = graph.getVertex(String.valueOf(rand_1));
            Vertex v = graph.getVertex(String.valueOf(rand_2));

            addEdge(u, v, 1);
        }

        clearAll();

        repaint();

    }