public static void drawRandConn(int N, double p) { StdDraw.setCanvasSize(512, 512); StdDraw.setScale(-1.0, 1.0); StdDraw.setPenRadius(.025); double[][] d = new double[N][2]; for (int i = 0; i < N; i++) { d[i][0] = Math.cos(2 * Math.PI * i / N); d[i][1] = Math.sin(2 * Math.PI * i / N); StdDraw.point(d[i][0], d[i][1]); } StdDraw.setPenRadius(); StdDraw.setPenColor(StdDraw.GRAY); for (int i = 0; i < N - 1; i++) for (int j = i + 1; j < N; j++) if (StdRandom.bernoulli(p)) StdDraw.line(d[i][0], d[i][1], d[j][0], d[j][1]); }
/** Draws this point to standard draw. */ public void draw() { /* DO NOT MODIFY */ StdDraw.point(x, y); }
// draw all points to standard draw public void draw() { for (Point2D point2D : root.subSet(LOWER, HIGHER)) { StdDraw.point(point2D.x(), point2D.y()); } }