public static void main(String[] args) throws IOException, FileNotFoundException {
		ArrayList<Edge> edges = new ArrayList<Edge>();
		final int K = 4;
		int n;

		BufferedReader br = new BufferedReader(new FileReader("clustering1.txt"));

		n =  Integer.parseInt(br.readLine());
		parents = new int[n][2];

		for(int i = 0; i < n ; i++){
			parents[i][0] = -1; // initialized parent for each node at begining, -1 indicates self-parent
			parents[i][1] = 0; // initialized parent for each node at begining, -1 indicates self-parent
		}

		String line;

		while((line = br.readLine())!=null){
			String[] split = line.trim().split("(\\s)+");
			int i = Integer.parseInt(split[0]);
			int j = Integer.parseInt(split[1]);
			int dist = Integer.parseInt(split[2]);
			edges.add(new Edge(i-1, j-1, dist));
		}
		br.close(); // done with reading

		Collections.sort(edges); // sorted from min to max by overrode method

		for(Edge e : edges){
			union(e.fr,e.to);
			if ((cluster_fusion_counter + K) == n) {
				System.out.println( K + " clusters were found ");
				break;				
			}
		}

		// print the max space among clusters.
		// scan through all edges again, find the min distance between any two clusters
		int max = Integer.MAX_VALUE;
		for (Edge e : edges){
			if (find(e.fr)!=find(e.to)) max=Math.min(max, e.cost);				
		}
		System.out.println("max spacing "+max);

	}