I want to run my function many times and get different answers(because it deals with random numbers), and get the minimum from all possible answers. But the function always returns the same value. How can I correct the loop to get different answers each time and find their minimum? Here is my code
int n = 0;
KargerMinimumCut karger = new KargerMinimumCut();
ArrayList<Integer> answers = new ArrayList<Integer>();
for(int i = 0; i < 10; i++) {
n = karger.minCut(vertices);
answers.add(n);
}
int min = minimum(answers);
System.out.println("Minimum Number is: " + min);
and the minimum function
public static int minimum(ArrayList<Integer> array) {
int min = array.get(0);
for(int i = 1; i < array.size(); i++) {
if(array.get(i) < min)
min = array.get(i);
}
return min;
}