* @param progress the progress object to actualize the current progress if
* the algorithm
*/
protected void expandClusterOrderDouble(ClusterOrderResult<DoubleDistance> clusterOrder, Database database, RangeQuery<O, DoubleDistance> rangeQuery, DBID objectID, DoubleDistance epsilon, FiniteProgress progress) {
UpdatableHeap<DoubleDistanceClusterOrderEntry> heap = new UpdatableHeap<DoubleDistanceClusterOrderEntry>();
heap.add(new DoubleDistanceClusterOrderEntry(objectID, null, Double.POSITIVE_INFINITY));
while(!heap.isEmpty()) {
final DoubleDistanceClusterOrderEntry current = heap.poll();
clusterOrder.add(current);
processedIDs.add(current.getID());
List<DistanceResultPair<DoubleDistance>> neighbors = rangeQuery.getRangeForDBID(current.getID(), epsilon);
if(neighbors.size() >= minpts) {
final DistanceResultPair<DoubleDistance> last = neighbors.get(minpts - 1);
if(last instanceof DoubleDistanceResultPair) {
double coreDistance = ((DoubleDistanceResultPair) last).getDoubleDistance();
for(DistanceResultPair<DoubleDistance> neighbor : neighbors) {
if(processedIDs.contains(neighbor.getDBID())) {
continue;
}
double reachability = Math.max(((DoubleDistanceResultPair) neighbor).getDoubleDistance(), coreDistance);
heap.add(new DoubleDistanceClusterOrderEntry(neighbor.getDBID(), current.getID(), reachability));
}
}
else {
// Actually we have little gains in this situation,
// Only if we got an optimized result before.
double coreDistance = last.getDistance().doubleValue();
for(DistanceResultPair<DoubleDistance> neighbor : neighbors) {
if(processedIDs.contains(neighbor.getDBID())) {
continue;
}
double reachability = Math.max(neighbor.getDistance().doubleValue(), coreDistance);
heap.add(new DoubleDistanceClusterOrderEntry(neighbor.getDBID(), current.getID(), reachability));
}
}
}
if(progress != null) {
progress.setProcessed(processedIDs.size(), logger);