import java.io.*;

class unitDiskGraph  extends myGenericListGraph<Integer>{

	private static BufferedReader stdin = new BufferedReader( new InputStreamReader( System.in ) );

	public unitDiskGraph(int n, int d)
	{

		// Make space for names array and Edges array
                names = new Integer[n];
                Edges = (GenericLinkList<Integer>[]) new GenericLinkList[n];
                for (int i = 0 ; i < n; i ++) 
                        Edges[i] = new GenericLinkList<Integer>();

		// Make space for the point array
		Point[] pointArray = new Point[n];	
		
		// Generate points and connect pairs of points at distance
		// at most one
		for(int i = 0; i < n; i++)
		{
			// Genereate a point uniformly in the d by d square
			Point p = new Point(d);
			pointArray[i] = p;
			addVertex(i);

			for(int j = 0; j < i; j++)
				if(p.distance(pointArray[j]) <= 1)
					addEdge(i, j);

		}

	}


        // Finds the location at which a vertex is stored in Vertices.
        // Returns -1 if vertex not found
        public int getIndex(Integer vertex)
        {
		int index = vertex.intValue();
		if((0 <= index)&&(index < numVertices))
			return index;
		
                return -1;
        }


	public static void main (String [] args) {
		int n = 0;

		try{
			// Prompt the user
            		System.out.println( "Type number of vertices in the graph (should be a positive integer). " );
            		// Read a line of text from the user.
            		String input = stdin.readLine();

			// converts a String into an int value
			n = Integer.parseInt( input ); 

		}
               	catch(java.io.IOException e)
               	{
               		System.out.println(e);
                }

		// Generate a bunch of UDGs for different values of d
		for(int d = 40; d < 50; d++)
		{
			// A function that takes n and d and creates a UDG with these
			// parameters in a way that is specified in the Project 1 handout
			unitDiskGraph g = new unitDiskGraph(n, d);

			System.out.println("Using d = "+d);

			System.out.println("The degree statistics for this graph are");
			System.out.println(g.averageDegree() + " " + g.maximumDegree() + " " +g.minimumDegree());

			if(g.isConnected())
				System.out.println("The average path length is "+g.averagePathLength());
			else
				System.out.println("The graph is not connected.");

			System.out.println("The clustering coefficient is "+g.clusteringCoefficient());
		}	
			
	}
}
