Graph(int V, double d) { Fence f1,f2; f1 = new Fence(new Point(0.5,0.2), new Point(0.5,0.8)); f2 = new Fence(new Point(0.2,0.5), new Point(0.8,0.5)); this.V = V; this.E = 0; adj = new Node[V]; p = new Point[V]; for (int i = 0; i < V; i++) p[i] = new Point(Math.random(), Math.random()); for (int i = 0; i < V; i++) adj[i] = new Node(i, null); for (int i = 0; i < V; i++) for (int j = i+1; j < V; j++) if ((Point.distance(p[i], p[j]) < d) && !Fence.cross(f1,p[i],p[j]) && !Fence.cross(f2,p[i],p[j])) { E++; adj[j].next = new Node(i, adj[j].next); adj[i].next = new Node(j, adj[i].next); } System.out.println(V + " vertices, " + E + " edges."); }