public static int getDiameter() {
		// Find the largest connected component.
		LinkedList<Person> nodes = new LinkedList<Person>();
		for (LinkedList<Person> component : components)
			if (component.size() > nodes.size())
				nodes = component;
		// Calculate its diameter (find the longest shortest path).
		long start = System.nanoTime();
	    int diameter = 0;
	    for (int i = 0; i < nodes.size(); i++) {
	        for (int j = i+1; j < nodes.size(); j++) {
	            int distance = distance(nodes.get(i), nodes.get(j));
	            if (distance > diameter)
	                diameter = distance;
	            // Abort if we're taking too long.
	            if (System.nanoTime() - start > 60000000)
	            	return -diameter;
	        }
	    }
	    return diameter;
	}