Environment for
DeveLoping
KDD-Applications
Supported by Index-Structures

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

java.lang.Object
  extended by de.lmu.ifi.dbs.elki.data.AbstractDatabaseObject
      extended by de.lmu.ifi.dbs.elki.data.cluster.Cluster<M>
Type Parameters:
M - Model object type
All Implemented Interfaces:
HierarchyInterface<Cluster<M>>, DatabaseObject, DatabaseObjectGroup, TextWriteable, Iterable<Integer>

public class Cluster<M extends Model>
extends AbstractDatabaseObject
implements HierarchyInterface<Cluster<M>>, DatabaseObjectGroup, TextWriteable

Generic cluster class, that may or not have hierarchical information. Note that every cluster MUST have a DatabaseObjectGroup, 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.

Author:
Erich Schubert

Field Summary
private  DatabaseObjectGroup group
          Cluster data.
private  HierarchyImplementation<Cluster<M>> hierarchy
          Object that the hierarchy management is delegated to.
private  M model
          Cluster model.
protected  String name
          Cluster name.
private  boolean noise
          Noise?
 
Constructor Summary
Cluster(DatabaseObjectGroup group)
          Constructor without hierarchy information and name and model
Cluster(DatabaseObjectGroup group, boolean noise)
          Constructor without hierarchy information and name and model
Cluster(DatabaseObjectGroup group, boolean noise, M model)
          Constructor without hierarchy information and name
Cluster(DatabaseObjectGroup group, M model)
          Constructor without hierarchy information and name
Cluster(String name, DatabaseObjectGroup group)
          Constructor without hierarchy information and model
Cluster(String name, DatabaseObjectGroup group, boolean noise)
          Constructor without hierarchy information and model
Cluster(String name, DatabaseObjectGroup group, boolean noise, M model)
          Constructor without hierarchy information.
Cluster(String name, DatabaseObjectGroup group, boolean noise, M model, HierarchyImplementation<Cluster<M>> hierarchy)
          Full constructor
Cluster(String name, DatabaseObjectGroup group, boolean noise, M model, List<Cluster<M>> children, List<Cluster<M>> parents)
          Constructor with hierarchy information.
Cluster(String name, DatabaseObjectGroup group, M model)
          Constructor without hierarchy information.
Cluster(String name, DatabaseObjectGroup group, M model, HierarchyImplementation<Cluster<M>> hierarchy)
          Constructor with hierarchy but noise flag defaulting to false.
Cluster(String name, DatabaseObjectGroup group, M model, List<Cluster<M>> children, List<Cluster<M>> parents)
          Constructor with hierarchy information, but no noise flag.
 
Method Summary
<T extends Collection<Cluster<M>>>
T
getAncestors(T collection)
          Delegate to hierarchy object
 List<Cluster<M>> getChildren()
          Delegate to hierarchy object
 Set<Cluster<M>> getDescendants()
          Collect descendants
<T extends Collection<Cluster<M>>>
T
getDescendants(T collection)
          Delegate to hierarchy object
 DatabaseObjectGroup getGroup()
          Access group object
 HierarchyImplementation<Cluster<M>> getHierarchy()
          Get hierarchy object
 Collection<Integer> getIDs()
          Delegate to group.
 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.
 Iterator<Integer> iterator()
          Delegate to group.
 int numChildren()
          Delegate to hierarchy object
 int numParents()
          Delegate to hierarchy object
 void setGroup(DatabaseObjectGroup g)
          Access group object
 void setHierarchy(HierarchyImplementation<Cluster<M>> hierarchy)
          Set hierarchy 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.
 void writeToText(TextWriterStream out, String label)
          Write to a textual representation.
 
Methods inherited from class de.lmu.ifi.dbs.elki.data.AbstractDatabaseObject
getID, setID
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface de.lmu.ifi.dbs.elki.data.DatabaseObject
equals
 

Field Detail

hierarchy

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


name

protected String name
Cluster name.


group

private DatabaseObjectGroup group
Cluster data.


model

private M extends Model model
Cluster model.


noise

private boolean noise
Noise?

Constructor Detail

Cluster

public Cluster(String name,
               DatabaseObjectGroup group,
               boolean noise,
               M model,
               HierarchyImplementation<Cluster<M>> hierarchy)
Full constructor

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

Cluster

public Cluster(String name,
               DatabaseObjectGroup group,
               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.
group - Group data
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,
               DatabaseObjectGroup group,
               boolean noise,
               M model)
Constructor without hierarchy information.

Parameters:
name -
group -
noise - Noise flag
model - Model

Cluster

public Cluster(String name,
               DatabaseObjectGroup group,
               M model)
Constructor without hierarchy information.

Parameters:
name -
group -
model - Model

Cluster

public Cluster(DatabaseObjectGroup group,
               boolean noise,
               M model)
Constructor without hierarchy information and name

Parameters:
group -
noise - Noise flag
model - Model

Cluster

public Cluster(DatabaseObjectGroup group,
               M model)
Constructor without hierarchy information and name

Parameters:
group -
model - Model

Cluster

public Cluster(String name,
               DatabaseObjectGroup group,
               boolean noise)
Constructor without hierarchy information and model

Parameters:
name - name
group -
noise - Noise flag

Cluster

public Cluster(String name,
               DatabaseObjectGroup group)
Constructor without hierarchy information and model

Parameters:
name -
group -

Cluster

public Cluster(DatabaseObjectGroup group,
               boolean noise)
Constructor without hierarchy information and name and model

Parameters:
group -
noise - Noise flag

Cluster

public Cluster(DatabaseObjectGroup group)
Constructor without hierarchy information and name and model

Parameters:
group -

Cluster

public Cluster(String name,
               DatabaseObjectGroup group,
               M model,
               HierarchyImplementation<Cluster<M>> hierarchy)
Constructor with hierarchy but noise flag defaulting to false.

Parameters:
name - Cluster name. May be null.
group - Group data
model - Model. May be null.
hierarchy - Hierarchy object. May be null.

Cluster

public Cluster(String name,
               DatabaseObjectGroup group,
               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.
group - Group data
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 HierarchyInterface<Cluster<M extends Model>>
Returns:
hierarchical data model.

numChildren

public int numChildren()
Delegate to hierarchy object

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

getChildren

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

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

getDescendants

public <T extends Collection<Cluster<M>>> T getDescendants(T collection)
Delegate to hierarchy object

Specified by:
getDescendants in interface HierarchyInterface<Cluster<M extends Model>>
Type Parameters:
T - collection type
Parameters:
collection - Collection to fill
Returns:
filled collection

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 HierarchyInterface<Cluster<M extends Model>>
Returns:
number of parents

getParents

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

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

getAncestors

public <T extends Collection<Cluster<M>>> T getAncestors(T collection)
Delegate to hierarchy object

Specified by:
getAncestors in interface HierarchyInterface<Cluster<M extends Model>>
Type Parameters:
T - collection type
Parameters:
collection - Collection to fill.
Returns:
filled collection

size

public int size()
Delegate to database object group.

Specified by:
size in interface DatabaseObjectGroup
Returns:
Cluster size retrieved from object group.

getIDs

public Collection<Integer> getIDs()
Delegate to group.

Specified by:
getIDs in interface DatabaseObjectGroup
Returns:
a collection of IDs

iterator

public Iterator<Integer> iterator()
Delegate to group.

Specified by:
iterator in interface DatabaseObjectGroup
Specified by:
iterator in interface Iterable<Integer>
Returns:
an iterator for the IDs

getHierarchy

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

Returns:
hierarchy object

setHierarchy

public void setHierarchy(HierarchyImplementation<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

getGroup

public DatabaseObjectGroup getGroup()
Access group object

Returns:
database object group

setGroup

public void setGroup(DatabaseObjectGroup 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 -

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

Release 0.2 (2009-07-06_1820)