@SuppressWarnings("unchecked") private void updateCluster(Instance inst, Cluster cluster) { if (inst instanceof Cluster) { // merge the clusters Cluster c = (Cluster)inst; for (String key : c.getCentroids().keySet()) { Centroid<Feature> update = c.getCentroids().get(key); Centroid<Feature> centroid = cluster.getCentroids().get(key); // get all the aggregate feature values associated with update for (Feature f : update.getAggregatableCentroid()) { centroid.add(f); } } // after merging cluster we should manually update the resulting centroid cluster.updateCentroid(); // TODO should handle merging the cluster members } else { // simply add the instance to the cluster cluster.add(inst); } }