public Graph<Node, Edge> generateRandomGraph(int nodes, double density) {
		Graph<Node, Edge> graph = new UndirectedSparseGraph<>();
		for (int n = 0; n < nodes; ++n) {
			Properties properties = new Properties();
			properties.put("id", String.valueOf(n));
			Node node = new Node(properties);
			node.setGroup("0");
			graph.addVertex(node);
		}
		ArrayList<Node> vertices = new ArrayList<Node>(graph.getVertices());

		int edges = (int) ((density * vertices.size() * (vertices.size() - 1)) / 2);
		for (int e = 0; e < edges; ++e) {
			while (true) {
				int firstNode = random.nextInt(nodes);
				int secondNode = random.nextInt(nodes);
				if (firstNode != secondNode && graph.findEdge(vertices.get(firstNode), vertices.get(secondNode)) == null) {
					graph.addEdge(new Edge(e), vertices.get(firstNode), vertices.get(secondNode));
					break;
				}
			}
		}
		return graph;
	}