Environment for
DeveLoping
KDD-Applications
Supported by Index-Structures

de.lmu.ifi.dbs.elki.algorithm.result.clustering
Class HierarchicalCluster<C extends HierarchicalCluster<C>>

java.lang.Object
  extended by de.lmu.ifi.dbs.elki.logging.AbstractLoggable
      extended by de.lmu.ifi.dbs.elki.algorithm.result.clustering.HierarchicalCluster<C>
Type Parameters:
C - the type of HierarchicalCluster used by this Result
All Implemented Interfaces:
Loggable, Enumeratable<C>, Comparable<C>
Direct Known Subclasses:
HierarchicalAxesParallelCorrelationCluster, HierarchicalCASHCluster, HierarchicalCorrelationCluster

public class HierarchicalCluster<C extends HierarchicalCluster<C>>
extends AbstractLoggable
implements Comparable<C>, Enumeratable<C>

Abstract super class for a hierarchical cluster that holds the ids of the objects belonging to this cluster and the children and parents of this cluster. Hierarchical clusters allow multiple inheritance and can be visualized in a graph.

Author:
Elke Achtert

Field Summary
private  List<C> children
          The children of this cluster.
private  Set<Integer> ids
          Holds the ids belonging to this cluster.
private  String label
          The label of this cluster, needed for graph visualization.
private  int level
          The level of this cluster within the graph visualization.
private  int levelIndex
          The index of this cluster within the level, needed for graph visualization.
private  List<C> parents
          The parents of this cluster.
 
Fields inherited from class de.lmu.ifi.dbs.elki.logging.AbstractLoggable
debug
 
Constructor Summary
HierarchicalCluster()
          Provides a new empty hierarchical cluster with the specified preference vector.
HierarchicalCluster(Set<Integer> ids, List<C> children, List<C> parents, String label, int level, int levelIndex)
          Provides a new hierarchical cluster the that holds the ids of the objects belonging to this cluster and the children and parents of this cluster.
 
Method Summary
 void addChild(C child)
          Adds a child cluster to this cluster.
 void addID(Integer id)
          Adds a new id to this cluster.
 void addIDs(List<Integer> ids)
          Adds the specified list of ids to this cluster.
 void addParent(C parent)
          Adds a parent to this cluster.
 int compareTo(C o)
          Compares this object with the specified object for order.
 boolean equals(Object o)
          Indicates whether some other object is "equal to" this one.
 C getChild(int i)
          Returns the child at the specified index.
 List<C> getChildren()
          Returns the children of this cluster.
 List<Integer> getIDs()
          Returns the ids belonging to this cluster.
 String getLabel()
          Returns the label of this cluster.
 int getLevel()
          Returns the level of this cluster.
 int getLevelIndex()
          Returns the index within the level of this cluster.
 C getParent(int i)
          Returns the parent at the specified index.
 List<C> getParents()
          Returns the parents of this cluster.
 int numChildren()
          Returns the number of children.
 int numParents()
          Returns the number of parents.
 void removeID(Integer id)
          Removes the specified id from the list of ids of this cluster.
 void setLabel(String label)
          Sets the label of this cluster.
 void setLevel(int level)
          Sets the level of this cluster.
 void setLevelIndex(int levelIndex)
          Sets the index within the level of this cluster.
 String toString()
          Returns the label of this HierarchicalCluster.
 
Methods inherited from class de.lmu.ifi.dbs.elki.logging.AbstractLoggable
debugFine, debugFiner, debugFinest, exception, message, progress, progress, progress, verbose, verbose, warning
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ids

private final Set<Integer> ids
Holds the ids belonging to this cluster.


children

private final List<C extends HierarchicalCluster<C>> children
The children of this cluster.


parents

private final List<C extends HierarchicalCluster<C>> parents
The parents of this cluster.


level

private int level
The level of this cluster within the graph visualization.


levelIndex

private int levelIndex
The index of this cluster within the level, needed for graph visualization.


label

private String label
The label of this cluster, needed for graph visualization.

Constructor Detail

HierarchicalCluster

public HierarchicalCluster()
Provides a new empty hierarchical cluster with the specified preference vector.


HierarchicalCluster

public HierarchicalCluster(Set<Integer> ids,
                           List<C> children,
                           List<C> parents,
                           String label,
                           int level,
                           int levelIndex)
Provides a new hierarchical cluster the that holds the ids of the objects belonging to this cluster and the children and parents of this cluster.

Parameters:
ids - the ids of the objects belonging to this cluster
children - the list of children of this cluster
parents - the list of parents of this cluster
label - the label of this cluster
level - the level of this cluster in the graph
levelIndex - the index of this cluster within the level
Method Detail

addID

public final void addID(Integer id)
Adds a new id to this cluster.

Parameters:
id - the id to be added

addIDs

public final void addIDs(List<Integer> ids)
Adds the specified list of ids to this cluster.

Parameters:
ids - the ids to be added

removeID

public final void removeID(Integer id)
Removes the specified id from the list of ids of this cluster.

Parameters:
id - the id to be removed

addChild

public final void addChild(C child)
Adds a child cluster to this cluster.

Parameters:
child - the child to be added.

getChildren

public final List<C> getChildren()
Returns the children of this cluster.

Returns:
the children of this cluster

addParent

public final void addParent(C parent)
Adds a parent to this cluster.

Parameters:
parent - the parent to be added.

getParents

public final List<C> getParents()
Returns the parents of this cluster.

Returns:
the parents of this cluster

getLevel

public final int getLevel()
Returns the level of this cluster.

Returns:
the level of this cluster

getLevelIndex

public final int getLevelIndex()
Returns the index within the level of this cluster.

Returns:
the index within the level

setLevelIndex

public final void setLevelIndex(int levelIndex)
Sets the index within the level of this cluster.

Parameters:
levelIndex - the index to be set

setLabel

public final void setLabel(String label)
Sets the label of this cluster.

Parameters:
label - the label of this cluster

getLabel

public String getLabel()
Returns the label of this cluster.

Returns:
the label of this cluster

setLevel

public void setLevel(int level)
Sets the level of this cluster.

Parameters:
level - the level to be set

toString

public final String toString()
Returns the label of this HierarchicalCluster.

Overrides:
toString in class Object
Returns:
the label of this HierarchicalCluster

getIDs

public final List<Integer> getIDs()
Returns the ids belonging to this cluster.

Returns:
the ids belonging to this cluster

compareTo

public final int compareTo(C o)
Compares this object with the specified object for order. Compares the both clusters w.r.t. their level and their index within the level in the graph.

Specified by:
compareTo in interface Comparable<C extends HierarchicalCluster<C>>
Parameters:
o - the Object to be compared.
Returns:
a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

equals

public final boolean equals(Object o)
Indicates whether some other object is "equal to" this one. Two clusters are equal if they have equal levels and equal indices within the level (i.e. if they have the same position in the graph).

Overrides:
equals in class Object
Parameters:
o - the reference object with which to compare.
Returns:
true if this object is the same as the obj argument; false otherwise.

numChildren

public final int numChildren()
Returns the number of children.

Specified by:
numChildren in interface Enumeratable<C extends HierarchicalCluster<C>>
Returns:
the number of children

numParents

public final int numParents()
Returns the number of parents.

Returns:
the number of parents

getChild

public final C getChild(int i)
Returns the child at the specified index.

Specified by:
getChild in interface Enumeratable<C extends HierarchicalCluster<C>>
Parameters:
i - the index of the child to be returned
Returns:
the child at the specified index

getParent

public final C getParent(int i)
Returns the parent at the specified index.

Parameters:
i - the index of the parent to be returned
Returns:
the parent at the specified index

Release 0.1 (2008-07-10_1838)