import java.util.*;
import java.lang.*;

public class experiments
{
	public static void main(String args[])
	{
		
		/* First part of the experiments */
		for (int i = 500; i<=950; i+=50)
		{
			wirelessNetwork g = new wirelessNetwork(10, i);
			System.out.println("For network with n="+i+": ");
			double average = ((double)g.graph.numEdges)/((double)g.graph.numVertices);
			System.out.println("    The average degree is "+average);
			System.out.println("    The maximum degree is "+g.getMaxDegree());
			
			/* Perform topology control */
			g.topologyControl();
			System.out.println("  After topology control: ");
			average = ((double)g.graph.numEdges)/((double)g.graph.numVertices);
			System.out.println("    The average degree is "+average);
			System.out.println("    The maximum degree is "+g.getMaxDegree());
			System.out.println();
		}
		
		
		
		/* Second part of the experiments */
		wirelessNetwork g = new wirelessNetwork(10, 1000);
		System.out.println("***********************************");
		for (int i=1; i<=10; i++)
		{
			/* Randomly pick two vertices as the source and destination */
			int i1 = (int)(1000*Math.random());
			int i2 = (int)(1000*Math.random());
			String node1 = "a"+i1;
			String node2 = "a"+i2;
			
			String[] route = g.compassRouting(node1, node2);
			System.out.println();
			System.out.println("Path generated from "+node1+" to "+node2+":");
			for (int k=0; k<route.length; k++)
			{
				System.out.print(" "+route[k]);
			}
			if (!node2.equals(route[route.length-1]))
			{
				System.out.println();
				System.out.println(" No route found...");
			}
			System.out.println();
			System.out.println(" Length of the path generated is "+(route.length-1));
		}
		
		
		/* Third part of the experiments */
		g.topologyControl();
		System.out.println();
		System.out.println("***********************************");
		System.out.println("After topology control...");
		for (int i=1; i<=10; i++)
		{
			int i1 = (int)(1000*Math.random());
			int i2 = (int)(1000*Math.random());
			String node1 = "a"+i1;
			String node2 = "a"+i2;
			String[] route = g.compassRouting(node1, node2);
			System.out.println();
			System.out.println("Path generated from "+node1+" to "+node2+":");
			for (int k=0; k<route.length; k++)
			{
				System.out.print(" "+route[k]);
			}
			if (!node2.equals(route[route.length-1]))
			{
				System.out.println();
				System.out.print(" No route found...");
			}
			System.out.println();
			System.out.println(" Length of the path is "+(route.length-1));
		}
	
	}
}
