de.lmu.ifi.dbs.elki.data
Class Cluster<M extends Model>

java.lang.Object
  extended by de.lmu.ifi.dbs.elki.data.Cluster<M>
Type Parameters:
M - Model object type
All Implemented Interfaces:
TextWriteable, Hierarchical<Cluster<M>>

public class Cluster<M extends Model>
extends Object
implements Hierarchical<Cluster<M>>, 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.


Nested Class Summary
static class Cluster.PartialComparator
          A partial comparator for Clusters, based on their name.
 
Field Summary
private  Hierarchy<Cluster<M>> hierarchy
          Object that the hierarchy management is delegated to.
private  DBIDs ids
          Cluster data.
private  M model
          Cluster model.
protected  String name
          Cluster name.
private  boolean noise
          Noise?
 
Constructor Summary
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(String name, DBIDs ids)
          Constructor without hierarchy information and model
Cluster(String name, DBIDs ids, boolean noise)
          Constructor without hierarchy information and model
Cluster(String name, DBIDs ids, boolean noise, M model)
          Constructor without hierarchy information.
Cluster(String name, DBIDs ids, boolean noise, M model, Hierarchy<Cluster<M>> hierarchy)
          Full constructor
Cluster(String name, DBIDs ids, boolean noise, M model, List<Cluster<M>> children, List<Cluster<M>> parents)
          Constructor with hierarchy information.
Cluster(String name, DBIDs ids, M model)
          Constructor without hierarchy information.
Cluster(String name, DBIDs ids, M model, Hierarchy<Cluster<M>> hierarchy)
          Constructor with hierarchy but noise flag defaulting to false.
Cluster(String name, DBIDs ids, M model, List<Cluster<M>> children, List<Cluster<M>> parents)
          Constructor with hierarchy information, but no noise flag.
 
Method Summary
 List<Cluster<M>> getChildren()
          Delegate to hierarchy object
 Set<Cluster<M>> getDescendants()
          Collect descendants
 Hierarchy<Cluster<M>> getHierarchy()
          Get hierarchy object
 DBIDs getIDs()
          Access group object
 M getModel()
          Access model object
 String getName()
          Get Cluster name.
 String getNameAutomatic()
          Return either the assigned name or the suggested label
 List<Cluster<M>> getParents()
          Delegate to hierarchy object
 boolean isHierarchical()
          Test hierarchy
 boolean isNoise()
          Getter for noise flag.
 IterableIterator<Cluster<M>> iterAncestors()
          Delegate to hierarchy object
 IterableIterator<Cluster<M>> iterDescendants()
          Delegate to hierarchy object
 int numChildren()
          Delegate to hierarchy object
 int numParents()
          Delegate to hierarchy object
 void setHierarchy(Hierarchy<Cluster<M>> hierarchy)
          Set hierarchy object
 void setIDs(DBIDs g)
          Access group object
 void setModel(M model)
          Access model object
 void setName(String name)
          Set Cluster name
 void setNoise(boolean noise)
          Setter for noise flag.
 int size()
          Delegate to database object group.
 String toString()
          
 void writeToText(TextWriterStream out, 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

hierarchy

private Hierarchy<Cluster<M extends Model>> hierarchy
Object that the hierarchy management is delegated to.


name

protected String name
Cluster name.


ids

private DBIDs ids
Cluster data.


model

private M extends Model model
Cluster model.


noise

private boolean noise
Noise?

Constructor Detail

Cluster

public Cluster(String name,
               DBIDs ids,
               boolean noise,
               M model,
               Hierarchy<Cluster<M>> hierarchy)
Full constructor

Parameters:
name - Cluster name. May be null.
ids - Object Group
noise - Noise flag
model - Model. May be null.
hierarchy - Hierarchy object. May be null.

Cluster

public Cluster(String name,
               DBIDs ids,
               boolean noise,
               M model,
               List<Cluster<M>> children,
               List<Cluster<M>> parents)
Constructor with hierarchy information. A new FullHierarchy object will be created to store the hierarchy information.

Parameters:
name - Cluster name. May be null.
ids - Object Group
noise - Noise flag
model - Model. May be null.
children - Children. Will NOT be copied.
parents - Parents. Will NOT be copied.

Cluster

public Cluster(String name,
               DBIDs ids,
               boolean noise,
               M model)
Constructor without hierarchy information.

Parameters:
name - Cluster name. May be null.
ids - Object group
noise - Noise flag
model - Model

Cluster

public Cluster(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(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(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

Cluster

public Cluster(String name,
               DBIDs ids,
               M model,
               Hierarchy<Cluster<M>> hierarchy)
Constructor with hierarchy but noise flag defaulting to false.

Parameters:
name - Cluster name. May be null.
ids - Object group
model - Model. May be null.
hierarchy - Hierarchy object. May be null.

Cluster

public Cluster(String name,
               DBIDs ids,
               M model,
               List<Cluster<M>> children,
               List<Cluster<M>> parents)
Constructor with hierarchy information, but no noise flag. A new FullHierarchy object will be created to store the hierarchy information.

Parameters:
name - Cluster name. May be null.
ids - Object Group
model - Model. May be null.
children - Children. Will NOT be copied.
parents - Parents. Will NOT be copied.
Method Detail

isHierarchical

public final boolean isHierarchical()
Test hierarchy

Specified by:
isHierarchical in interface Hierarchical<Cluster<M extends Model>>
Returns:
hierarchical data model.

numChildren

public int numChildren()
Delegate to hierarchy object

Specified by:
numChildren in interface Hierarchical<Cluster<M extends Model>>
Returns:
number of children

getChildren

public List<Cluster<M>> getChildren()
Delegate to hierarchy object

Specified by:
getChildren in interface Hierarchical<Cluster<M extends Model>>
Returns:
list of children

iterDescendants

public IterableIterator<Cluster<M>> iterDescendants()
Delegate to hierarchy object

Specified by:
iterDescendants in interface Hierarchical<Cluster<M extends Model>>
Returns:
iterator for descendants

getDescendants

public Set<Cluster<M>> getDescendants()
Collect descendants

Returns:
Set of descendants

numParents

public int numParents()
Delegate to hierarchy object

Specified by:
numParents in interface Hierarchical<Cluster<M extends Model>>
Returns:
number of parents

getParents

public List<Cluster<M>> getParents()
Delegate to hierarchy object

Specified by:
getParents in interface Hierarchical<Cluster<M extends Model>>
Returns:
list of parents

iterAncestors

public IterableIterator<Cluster<M>> iterAncestors()
Delegate to hierarchy object

Specified by:
iterAncestors in interface Hierarchical<Cluster<M extends Model>>
Returns:
iterator for ancestors

size

public int size()
Delegate to database object group.

Returns:
Cluster size retrieved from object group.

getHierarchy

public Hierarchy<Cluster<M>> getHierarchy()
Get hierarchy object

Returns:
hierarchy object

setHierarchy

public void setHierarchy(Hierarchy<Cluster<M>> hierarchy)
Set hierarchy object

Parameters:
hierarchy - new hierarchy object

getNameAutomatic

public String getNameAutomatic()
Return either the assigned name or the suggested label

Returns:
a name for the cluster

getName

public String getName()
Get Cluster name. May be null.

Returns:
cluster name, or null

setName

public void setName(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,
                        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 String toString()

Overrides:
toString in class Object

Release 0.4.0 (2011-09-20_1324)