*/
public Clustering<Model> run(Relation<Model> relation) {
// Build model mapping
HashMap<Model, ModifiableDBIDs> modelMap = new HashMap<Model, ModifiableDBIDs>();
for(DBID id : relation.iterDBIDs()) {
Model model = relation.get(id);
ModifiableDBIDs modelids = modelMap.get(model);
if(modelids == null) {
modelids = DBIDUtil.newHashSet();
modelMap.put(model, modelids);
}
modelids.add(id);
}
Clustering<Model> result = new Clustering<Model>("By Model Clustering", "bymodel-clustering");
for(Entry<Model, ModifiableDBIDs> entry : modelMap.entrySet()) {
final Model model = entry.getKey();
final ModifiableDBIDs ids = entry.getValue();
final String name = (model instanceof GeneratorInterface) ? ((GeneratorInterface) model).getName() : model.toString();
Cluster<Model> c = new Cluster<Model>(name, ids, model);
if(noisepattern != null && noisepattern.matcher(name).find()) {
c.setNoise(true);
}
result.addCluster(c);