package org.neuroph.nnet.learning.kmeans;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

/**
 * This class represents a single cluster, with corresponding centroid and assigned vectors
 * @author Zoran Sevarac
 */
public class Cluster {    
    
    /**
     * Centroid for this cluster
     */
    KVector centroid;
    
    /**
     * Vectors assigned to this cluster during clustering
     */
    List vectors;    

    
    public Cluster() {
        this.vectors = new ArrayList<>();
    }
   
    public KVector getCentroid() {
        return centroid;
    }

    public void setCentroid(KVector centroid) {
        this.centroid = centroid;
    }
    
    
    public void removePoint(KVector point) {
        vectors.remove(point);
    }

    public List getPoints() {
        return vectors;
    }
    
    /**
     * Calculate and return avg sum vector for all vectors
     * @return avg sum vector 
     */
    public double[] getAvgSum() {
        double size = vectors.size();
        double[] avg = new double[vectors.get(0).size()];
        
        for(KVector item : vectors) {
            double[] values = item.getValues();
            
            for(int i=0; i 

Ads help maintain this website.