public static Graph createGraph(int vertexCount, boolean isUndirected) {
        Graph g = new Graph();

        int r = RandomGenerator.generateRandom(1, 1000); // to bring some randomness into indices
        for (int i = 1; i <= vertexCount; i++) {
            g.addVertex(i + r);
        }
        for (Vertex tailVertex : g.getVertices()) {
            List<Vertex> edges = g.getEdges(tailVertex);
            List<Integer> excludeList = new ArrayList<>();
            for (Vertex vertex : edges) {
                // These edges are already present no need to add them again
                excludeList.add(vertex.getIndex());
            }

            // No need to add edge to itself
            excludeList.add(tailVertex.getIndex());

            // will generate number between 1 and 9 both inclusive
            int randomNumber = RandomGenerator.generateRandom(1, 10);
            int edgeCount = randomNumber % 4 == 0 ? 2 : 1; // 2/9 probability that 2 edges will be there
            if (randomNumber % 9 == 0) { // 1/9 probability that this vertex will not have any outgoing edges
                continue;
            }

            Integer[] headVertices = RandomGenerator.uniqueRandoms(1 + r, vertexCount + r + 1, edgeCount, excludeList);

            for (Integer vertexIndex : headVertices) {
                Vertex headVertex = Vertex.getVertex(vertexIndex);
                g.addEdge(tailVertex, headVertex);
                if (isUndirected) {
                    g.addEdge(headVertex, tailVertex); // if undirected graph, adding edge in reverse direction also
                }
            }
        }
        return g;
    }