private static SphereCluster calculateCenter(ArrayList<Cluster> cluster, int dimensions) {
        double[] res = new double[dimensions];
        for (int i = 0; i < res.length; i++) {
            res[i] = 0.0;
        }

        if (cluster.size() == 0) {
            return new SphereCluster(res, 0.0);
        }

        for (Cluster point : cluster) {
            double[] center = point.getCenter();
            for (int i = 0; i < res.length; i++) {
                res[i] += center[i];
            }
        }

        // Normalize
        for (int i = 0; i < res.length; i++) {
            res[i] /= cluster.size();
        }

        // Calculate radius
        double radius = 0.0;
        for (Cluster point : cluster) {
            double dist = distance(res, point.getCenter());
            if (dist > radius) {
                radius = dist;
            }
        }
        SphereCluster sc = new SphereCluster(res, radius);
        sc.setWeight(cluster.size());
        return sc;
    }