/*
 * Represents an abstraction for a data point in two dimensional space
 *
 * Manas Somaiya
 * Computer and Information Science and Engineering
 * University of Florida
 *
 * Created: October 29, 2003
 * Last updated: October 30, 2003
 *
 */
package medusa.spectral;



/**
 * Represents an abstraction for a data point in two dimensional space
 * @author	Manas Somaiya	mhs@cise.ufl.edu
 */
public class KMeansPoint {

    /** Label */
    private String label;
    
    /** Assigned cluster */
    private int clusterNumber;
    private double[] coords;
    

    
    public int getDimensions(){
        return coords.length;
    }

    /**
     * Creates a new instance of data point
     *
     * @param	_x	value in dimension x
     * @param	_y	value in dimension y
     */
    public KMeansPoint(String label, double _x, double _y) {
        this.label = label;
        coords=new double[2];
        coords[0] = _x;
        coords[1] = _y;
        this.clusterNumber = 0;
    } // end of kMeansPoint()
    
       public KMeansPoint(String label, double[] coords) {
        this.label = label;
        this.coords=coords;
        
        this.clusterNumber = 0;
    } // end of kMeansPoint()


    /**
     * Assigns the data point to a cluster
     *
     * @param	_clusterNumber	the cluster to which this data point is to be assigned
     */
    public void assignToCluster(int _clusterNumber) {

        this.clusterNumber = _clusterNumber;

    } // end of assignToCluster()


    /**
     * Returns the cluster to which the data point belongs
     *
     * @return	the cluster number to which the data point belongs
     */
    public int getClusterNumber() {

        return this.clusterNumber;

    } // end of getClusterNumber()


  
    
    public double[] getCoords(){
        return coords;
    }


    /**
     * Returns the distance between two data points
     *
     * @param	dp1 	the first data point
     * @param	dp2 	the second data point
     * @return	the distance between the two data points
     */
    public static double distance(KMeansPoint dp1, KMeansPoint dp2) {

            double[] coords1=dp1.getCoords();
           double[] coords2=dp2.getCoords(); 
           
        double result = 0;
        for (int i=0; i 

Ads help maintain this website.