public static ClusterInfo computeClusterInfos(Cluster cluster, Distance distanceFunction) {
        ClusterInfo info = new ClusterInfo(cluster.isInverse(), true);
        for (int i = 0, j = cluster.getPoints().size(); i < j; i++) {
            Point point = cluster.getPoints().get(i);
            //shouldn't need to inverse here. other parts of
            //the code should interpret the "distance" or score here
            double distance = Nd4j.getExecutioner()
                            .execAndReturn(ClusterUtils.createDistanceFunctionOp(distanceFunction,
                                            cluster.getCenter().getArray(), point.getArray()))
                            .getFinalResult().doubleValue();
            info.getPointDistancesFromCenter().put(point.getId(), distance);
            double diff = info.getTotalPointDistanceFromCenter() + distance;
            info.setTotalPointDistanceFromCenter(diff);
        }

        if (!cluster.getPoints().isEmpty())
            info.setAveragePointDistanceFromCenter(info.getTotalPointDistanceFromCenter() / cluster.getPoints().size());
        return info;
    }
public static ClusterInfo computeClusterInfos ( Cluster cluster , Distance distanceFunction ) { ClusterInfo info = new ClusterInfo ( cluster . isInverse ( ) , true ) ; for ( int i = 0 , j = cluster . getPoints ( ) . size ( ) ; i < j ; i ++ ) { Point point = cluster . getPoints ( ) . get ( i ) ; double distance = Nd4j . getExecutioner ( ) . execAndReturn ( ClusterUtils . createDistanceFunctionOp ( distanceFunction , cluster . getCenter ( ) . getArray ( ) , point . getArray ( ) ) ) . getFinalResult ( ) . doubleValue ( ) ; info . getPointDistancesFromCenter ( ) . put ( point . getId ( ) , distance ) ; double diff = info . getTotalPointDistanceFromCenter ( ) + distance ; info . setTotalPointDistanceFromCenter ( diff ) ; } if ( ! cluster . getPoints ( ) . isEmpty ( ) ) info . setAveragePointDistanceFromCenter ( info . getTotalPointDistanceFromCenter ( ) / cluster . getPoints ( ) . size ( ) ) ; return info ; }
@param cluster
@param distanceFunction
@return