View Javadoc

    1   package baseCode.algorithm.learning.unsupervised.cluster;
    2
    3   import java.util.Collection;
    4   import java.util.Vector;
    5
    6   import baseCode.common.Distanceable;
    7
    8   /***
    9    * <hr>
    10   * <p>
    11   * Copyright (c) 2004 Columbia University
    12   *
    13   * @author pavlidis
    14   * @version $Id: Cluster.java,v 1.3 2004/08/11 22:53:43 pavlidis Exp $
    15   */
    16  public class Cluster extends Distanceable {
    17
    18     protected Distancer distAlg;
    19     protected Collection items;
    20
    21     public Cluster() {}
    22
    23     public Cluster(Object item, Distancer distAlg) {
    24        this.distAlg = distAlg;
    25        Vector v = new Vector();
    26        v.add(item);
    27        this.items = v;
    28     }
    29
    30     public Cluster( Collection items, Distancer distAlg ) {
    31        this.distAlg = distAlg;
    32        this.items = items;
    33     }
    34
    35     public void addItem(Cluster item ) {
    36
    37     }
    38
    39     /***
    40      *
    41      * @return true if this cluster is made up of multiple distanceables, or multiple ones.
    42      */
    43     public boolean isCompound() {
    44        return items != null && items.size() > 1;
    45     }
    46
    47
    48     /*
    49      * (non-Javadoc)
    50      *
    51      * @see baseCode.common.Distanceable#distanceTo(baseCode.common.Distanceable)
    52      */
    53     public double distanceTo( Distanceable a ) {
    54        return this.distAlg.distance( this, a );
    55     }
    56
    57     /*
    58      * (non-Javadoc)
    59      *
    60      * @see java.lang.Comparable#compareTo(java.lang.Object)
    61      */
    62     public int compareTo( Object o ) {
    63        // TODO Auto-generated method stub
    64        return 0;
    65     }
    66
    67     /*
    68      * (non-Javadoc)
    69      *
    70      * @see baseCode.common.Distanceable#toCollection()
    71      */
    72     public Collection toCollection() {
    73        return items;
    74     }
    75
    76  }