import java.util.*; public class GenerateSparseInstance { public static void main(String args[]) { int numberOfCities = 100; // Ok, I am fixing the seed, so that instead of reading in the // data from the text files, you can use this function to // generate the data I posted. Random r = new Random(0); Random t = new Random(0); for (int i = 0; i < numberOfCities; i++) { for (int j = i + 1; j < numberOfCities; j++) { if (t.nextInt(10) == 0) { System.out.println(i + " " + j + " " + (r.nextInt(100) + 1)); } else { r.nextInt(100); } } } } }