public static UndirectedGraph<Vertex> createGraph(int n, double p) {
		int rows = (int) Math.sqrt(n);
		int cols = (int) Math.ceil((double) n / rows);
		UndirectedGraph<Vertex> g = new UndirectedGraph<Vertex>(rows, cols);
		Random rands = new Random();
		for(int i = 0; i < n; i++) {
			g.addVertex(new Vertex(i / cols, i % cols));
		}
		int[] offs = { 1, cols - 1, cols, cols + 1 };
		for(int u = 0; u < n; u++) {
			for(int j = 0; j < offs.length; j++) {
				int v = u + offs[j];
				if(v >= 0 && v < n && rands.nextDouble() < p) {
					Vertex uu = g.getVertex(u);
					Vertex vv = g.getVertex(v);
					if(Math.abs(uu.getColumn() - vv.getColumn()) <= 1) {
						g.addEdge(uu, vv);
					}
				}
			}
		}
		return g;
	}