@Override public Clustering<MeanModel> run(Database database,Relation<V> relation){
  final DBIDs ids=relation.getDBIDs();
  double[][] means=initializer.chooseInitialMeans(database,relation,k,getDistanceFunction());
  List<ModifiableDBIDs> clusters=new ArrayList<>();
  for (int i=0; i < k; i++) {
    clusters.add(DBIDUtil.newHashSet(relation.size() / k + 2));
  }
  final WritableDataStore<Meta> metas=initializeMeta(relation,means);
  ArrayModifiableDBIDs tids=initialAssignment(clusters,metas,ids);
  means=means(clusters,means,relation);
  means=refineResult(relation,means,clusters,metas,tids);
  Clustering<MeanModel> result=new Clustering<>("k-Means Samesize Clustering","kmeans-samesize-clustering");
  for (int i=0; i < clusters.size(); i++) {
    result.addToplevelCluster(new Cluster<>(clusters.get(i),new MeanModel(means[i])));
  }
  return result;
}

@ Override public Clustering < MeanModel > run ( Database database , Relation < V > relation ) { final DBIDs ids = relation . getDBIDs ( ) ; double [ ] [ ] means = initializer . chooseInitialMeans ( database , relation , k , getDistanceFunction ( ) ) ; List < ModifiableDBIDs > clusters = new ArrayList < > ( ) ; for ( int i = 0 ; i < k ; i ++ ) { clusters . add ( DBIDUtil . newHashSet ( relation . size ( ) / k + 2 ) ) ; } final WritableDataStore < Meta > metas = initializeMeta ( relation , means ) ; ArrayModifiableDBIDs tids = initialAssignment ( clusters , metas , ids ) ; means = means ( clusters , means , relation ) ; means = refineResult ( relation , means , clusters , metas , tids ) ; Clustering < MeanModel > result = new Clustering < > ( "k-Means Samesize Clustering" , "kmeans-samesize-clustering" ) ; for ( int i = 0 ; i < clusters . size ( ) ; i ++ ) { result . addToplevelCluster ( new Cluster < > ( clusters . get ( i ) , new MeanModel ( means [ i ] ) ) ) ; } return result ; }
run k - means with cluster size constraints .
