- java.lang.Object
-
- elki.data.Cluster<M>
-
- 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_SORTERA partial comparator for Clusters, based on their name.private DBIDsidsCluster data.private MmodelCluster model.protected java.lang.StringnameCluster name.private booleannoiseNoise?
-
Constructor Summary
Constructors Constructor Description Cluster(DBIDs ids)Constructor without hierarchy information and name and modelCluster(DBIDs ids, boolean noise)Constructor without hierarchy information and name and modelCluster(DBIDs ids, boolean noise, M model)Constructor without hierarchy information and nameCluster(DBIDs ids, M model)Constructor without hierarchy information and nameCluster(java.lang.String name, DBIDs ids)Constructor without hierarchy information and modelCluster(java.lang.String name, DBIDs ids, boolean noise)Constructor without hierarchy information and modelCluster(java.lang.String name, DBIDs ids, boolean noise, M model)Full constructorCluster(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 DBIDsgetIDs()Access group objectMgetModel()Access model objectjava.lang.StringgetName()Get Cluster name.java.lang.StringgetNameAutomatic()Return either the assigned name or the suggested labelbooleanisNoise()Getter for noise flag.voidsetIDs(DBIDs g)Access group objectvoidsetModel(M model)Access model objectvoidsetName(java.lang.String name)Set Cluster namevoidsetNoise(boolean noise)Setter for noise flag.intsize()Delegate to database object group.java.lang.StringtoString()voidwriteToText(TextWriterStream out, java.lang.String label)Write to a textual representation.
-
-
-
Field Detail
-
name
protected java.lang.String name
Cluster name.
-
ids
private DBIDs ids
Cluster data.
-
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 Groupnoise- Noise flagmodel- 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 groupmodel- Model
-
Cluster
public Cluster(DBIDs ids, boolean noise, M model)
Constructor without hierarchy information and name- Parameters:
ids- Object groupnoise- Noise flagmodel- Model
-
Cluster
public Cluster(DBIDs ids, M model)
Constructor without hierarchy information and name- Parameters:
ids- Object groupmodel- 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 groupnoise- 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:
writeToTextin interfaceTextWriteable- Parameters:
out- output writer streamlabel- 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:
toStringin classjava.lang.Object
-
-