public int getMinimum() {
        int res = -1;
        int min = -1;
        for (int i = 0; i < result.length; i++) {
            if (result[i] != -1 && visited[i] != 1 && (result[i] < min || min == -1)) {
                min = result[i];
                res = i;
            }
        }
        return res;
    }