Package elki.data

Class Cluster<M extends Model>

  • Type Parameters:
    M - Model object type
    All Implemented Interfaces:
    TextWriteable

    public class Cluster<M extends Model>
    extends java.lang.Object
    implements TextWriteable
    Generic cluster class, that may or not have hierarchical information. Note that every cluster MUST have a DBIDs, since it implements the interface, too. Calls to the interface are proxied to the inner group object.

    A hierarchy object of class SimpleHierarchy will be created automatically when a list of parents and children is provided. Alternatively, a pre-existing hierarchy object can be provided, e.g., when there is a single hierarchy object used for keeping all the hierarchy information in one object.

    Since:
    0.2
    Author:
    Erich Schubert
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.util.Comparator<Cluster<?>> BY_NAME_SORTER
      A partial comparator for Clusters, based on their name.
      private DBIDs ids
      Cluster data.
      private M model
      Cluster model.
      protected java.lang.String name
      Cluster name.
      private boolean noise
      Noise?
    • Constructor Summary

      Constructors 
      Constructor Description
      Cluster​(DBIDs ids)
      Constructor without hierarchy information and name and model
      Cluster​(DBIDs ids, boolean noise)
      Constructor without hierarchy information and name and model
      Cluster​(DBIDs ids, boolean noise, M model)
      Constructor without hierarchy information and name
      Cluster​(DBIDs ids, M model)
      Constructor without hierarchy information and name
      Cluster​(java.lang.String name, DBIDs ids)
      Constructor without hierarchy information and model
      Cluster​(java.lang.String name, DBIDs ids, boolean noise)
      Constructor without hierarchy information and model
      Cluster​(java.lang.String name, DBIDs ids, boolean noise, M model)
      Full constructor
      Cluster​(java.lang.String name, DBIDs ids, M model)
      Constructor without hierarchy information.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      DBIDs getIDs()
      Access group object
      M getModel()
      Access model object
      java.lang.String getName()
      Get Cluster name.
      java.lang.String getNameAutomatic()
      Return either the assigned name or the suggested label
      boolean isNoise()
      Getter for noise flag.
      void setIDs​(DBIDs g)
      Access group object
      void setModel​(M model)
      Access model object
      void setName​(java.lang.String name)
      Set Cluster name
      void setNoise​(boolean noise)
      Setter for noise flag.
      int size()
      Delegate to database object group.
      java.lang.String toString()  
      void writeToText​(TextWriterStream out, java.lang.String label)
      Write to a textual representation.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • name

        protected java.lang.String name
        Cluster name.
      • ids

        private DBIDs ids
        Cluster data.
      • model

        private M extends Model model
        Cluster model.
      • noise

        private boolean noise
        Noise?
      • BY_NAME_SORTER

        public static final java.util.Comparator<Cluster<?>> BY_NAME_SORTER
        A partial comparator for Clusters, based on their name. Useful for sorting clusters. Do NOT use in, e.g., a TreeSet since it is inconsistent with equals.
    • Constructor Detail

      • Cluster

        public Cluster​(java.lang.String name,
                       DBIDs ids,
                       boolean noise,
                       M model)
        Full constructor
        Parameters:
        name - Cluster name. May be null.
        ids - Object Group
        noise - Noise flag
        model - Model. May be null.
      • Cluster

        public Cluster​(java.lang.String name,
                       DBIDs ids,
                       M model)
        Constructor without hierarchy information.
        Parameters:
        name - Cluster name. May be null.
        ids - Object group
        model - Model
      • Cluster

        public Cluster​(DBIDs ids,
                       boolean noise,
                       M model)
        Constructor without hierarchy information and name
        Parameters:
        ids - Object group
        noise - Noise flag
        model - Model
      • Cluster

        public Cluster​(DBIDs ids,
                       M model)
        Constructor without hierarchy information and name
        Parameters:
        ids - Object group
        model - Model
      • Cluster

        public Cluster​(java.lang.String name,
                       DBIDs ids,
                       boolean noise)
        Constructor without hierarchy information and model
        Parameters:
        name - Cluster name. May be null.
        ids - Object group
        noise - Noise flag
      • Cluster

        public Cluster​(java.lang.String name,
                       DBIDs ids)
        Constructor without hierarchy information and model
        Parameters:
        name - Cluster name. May be null.
        ids - Object group
      • Cluster

        public Cluster​(DBIDs ids,
                       boolean noise)
        Constructor without hierarchy information and name and model
        Parameters:
        ids - Cluster name. May be null.
        noise - Noise flag
      • Cluster

        public Cluster​(DBIDs ids)
        Constructor without hierarchy information and name and model
        Parameters:
        ids - Object group
    • Method Detail

      • size

        public int size()
        Delegate to database object group.
        Returns:
        Cluster size retrieved from object group.
      • getNameAutomatic

        public java.lang.String getNameAutomatic()
        Return either the assigned name or the suggested label
        Returns:
        a name for the cluster
      • getName

        public java.lang.String getName()
        Get Cluster name. May be null.
        Returns:
        cluster name, or null
      • setName

        public void setName​(java.lang.String name)
        Set Cluster name
        Parameters:
        name - new cluster name
      • getIDs

        public DBIDs getIDs()
        Access group object
        Returns:
        database object group
      • setIDs

        public void setIDs​(DBIDs g)
        Access group object
        Parameters:
        g - set database object group
      • getModel

        public M getModel()
        Access model object
        Returns:
        Cluster model
      • setModel

        public void setModel​(M model)
        Access model object
        Parameters:
        model - New cluster model
      • writeToText

        public void writeToText​(TextWriterStream out,
                                java.lang.String label)
        Write to a textual representation. Writing the actual group data will be handled by the caller, this is only meant to write the meta information.
        Specified by:
        writeToText in interface TextWriteable
        Parameters:
        out - output writer stream
        label - Label to prefix
      • isNoise

        public boolean isNoise()
        Getter for noise flag.
        Returns:
        noise flag
      • setNoise

        public void setNoise​(boolean noise)
        Setter for noise flag.
        Parameters:
        noise - new noise flag value
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object