I have a hashmap containing 6 elements as I have - E : [x1:0.4, x2: 0.5 , x3: 0.56, x4: 0.45] -
What I'm trying to do is to over each element, until the E is empty.
The problem here is that it retrieves the first min, and stops, yet the E hashmap still contains elements, what is it that I'm missing HashMap E = new HashMap<>(); // not that E is not empty and it is instantiated above
HashSet<Integer> dataPoints = new HashSet(); //list of points for each xmin
HashMap<Integer, List<Integer>> clusters = new HashMap<>();
ArrayList<Integer> listt = new ArrayList<>();
List<Integer> l = new ArrayList<>(); //list of points for each xmin
System.out.println("size one :"+dataPoints.size());
while (!E.isEmpty()) {
int xMin = getKey(E, MinX(E, dataPoints));
dataPoints.add(xMin);
System.out.println("Xmin " + xMin);
E.remove(xMin);
//checking id X exists in data points if no return close elements
for (int j = 0; j < S.getRow(xMin).length; j++) {
if (S.getEntry(xMin, j) > beta) {
l.add(j);
dataPoints.add(j);
E.remove(j);
}
}
clusters.put(xMin, l);
here is the Minx function
public double MinX(ConcurrentMap<Integer, Double> e, HashSet<Integer> h) {
double tmpMin = 1;
//int Xmin = 0;
for (int k = 0; k < e.size(); k++) {
if ((e.get(k) < tmpMin) && (!h.contains(e.get(k)))) {
tmpMin = e.get(k);
}
}
return tmpMin;
};
Now this is giving me null pointer exception ```
at MinX()