views:

5

answers:

0

I am working on implementing a recursive depth first search, my issue is maintaining visited elements in my ArrayList. I have double values but the way using a boolean[], I have to type cast it to int, once you do that you no longer work with the same value.

Here is what I have so far, any help would be greatly appreciate

public void dfsNearestNeighbor(double point, ArrayList<Double> list, boolean[] pointIsVisited ) {
 if (point != 0.0) {
  list.add(point);
  cluster.add(point);
  pointIsVisited[(int) point] = true;
  double newNeighbor =  nearestNeighbor(point);
  if (newNeighbor !=  0.0) {
   cluster.add(newNeighbor);
   for (int i = 0; i < tempList.size(); i++) {
    if (!pointIsVisited[i]) {
     dfsNearestNeighbor(newNeighbor, list, pointIsVisited);
    }
   }
  }
 }
}