private static SphereCluster calculateCenter(ArrayList<Cluster> assigned,int dimensions){
  double[] result=new double[dimensions];
  for (int i=0; i < result.length; i++) {
    result[i]=0.0;
  }
  if (assigned.size() == 0) {
    return new SphereCluster(result,0.0);
  }
  for (  Cluster point : assigned) {
    double[] center=point.getCenter();
    for (int i=0; i < result.length; i++) {
      result[i]+=center[i];
    }
  }
  for (int i=0; i < result.length; i++) {
    result[i]/=assigned.size();
  }
  double radius=0.0;
  for (  Cluster point : assigned) {
    double dist=distance(result,point.getCenter());
    if (dist > radius) {
      radius=dist;
    }
  }
  SphereCluster sc=new SphereCluster(result,radius);
  sc.setWeight(assigned.size());
  return sc;
}

private static SphereCluster calculateCenter ( ArrayList < Cluster > assigned , int dimensions ) { double [ ] result = new double [ dimensions ] ; for ( int i = 0 ; i < result . length ; i ++ ) { result [ i ] = 0.0 ; } if ( assigned . size ( ) == 0 ) { return new SphereCluster ( result , 0.0 ) ; } for ( Cluster point : assigned ) { double [ ] center = point . getCenter ( ) ; for ( int i = 0 ; i < result . length ; i ++ ) { result [ i ] += center [ i ] ; } } for ( int i = 0 ; i < result . length ; i ++ ) { result [ i ] /= assigned . size ( ) ; } double radius = 0.0 ; for ( Cluster point : assigned ) { double dist = distance ( result , point . getCenter ( ) ) ; if ( dist > radius ) { radius = dist ; } } SphereCluster sc = new SphereCluster ( result , radius ) ; sc . setWeight ( assigned . size ( ) ) ; return sc ; }
k - means helper : calculate a wrapping cluster of assigned points [ microclusters ] .
