Environment for
DeveLoping
KDD-Applications
Supported by Index-Structures

de.lmu.ifi.dbs.elki.algorithm.result.clustering
Class HierarchicalClusters<C extends HierarchicalCluster<C>,O extends DatabaseObject>

java.lang.Object
  extended by de.lmu.ifi.dbs.elki.logging.AbstractLoggable
      extended by de.lmu.ifi.dbs.elki.algorithm.result.AbstractResult<O>
          extended by de.lmu.ifi.dbs.elki.algorithm.result.clustering.HierarchicalClusters<C,O>
Type Parameters:
O - the type of DatabaseObjects handled by this Result
C - the type of HierarchicalCluster used by this Result
All Implemented Interfaces:
Result<O>, Loggable
Direct Known Subclasses:
HierarchicalAxesParallelCorrelationClusters, HierarchicalCASHClusters, HierarchicalCorrelationClusters

public class HierarchicalClusters<C extends HierarchicalCluster<C>,O extends DatabaseObject>
extends AbstractResult<O>

Provides a result of a clustering algorithm that computes hierarchical clusters.

Author:
Elke Achtert

Field Summary
static String CHILDREN
          Indicating the children of a cluster in the string representation.
static String LEVEL
          Indicating the level of a cluster in the string representation.
static String LEVEL_INDEX
          Indicating the index within the level of a cluster in the string representation.
static String PARENTS
          Indicating the parents of a cluster in the string representation.
private  List<C> rootClusters
          The root clusters.
 
Fields inherited from class de.lmu.ifi.dbs.elki.algorithm.result.AbstractResult
db, FILE_EXTENSION
 
Fields inherited from class de.lmu.ifi.dbs.elki.logging.AbstractLoggable
debug
 
Fields inherited from interface de.lmu.ifi.dbs.elki.algorithm.result.Result
SEPARATOR
 
Constructor Summary
HierarchicalClusters(C rootCluster, Database<O> db)
          Provides a result of a clustering algorithm that computes hierarchical clusters from a cluster order.
HierarchicalClusters(List<C> rootClusters, Database<O> db)
          Provides a result of a clustering algorithm that computes hierarchical clusters from a cluster order.
 
Method Summary
 List<C> getRootClusters()
          Returns the root clusters.
 void output(File dir, Normalization<O> normalization, List<AttributeSettings> settings)
          Writes the clustering result to the given file.
 void output(PrintStream outStream, Normalization<O> normalization, List<AttributeSettings> settings)
          Writes the cluster order to the given stream.
private  void write(C cluster, File dir, PrintStream out, Normalization<O> normalization, List<AttributeSettings> settings, List<String> headerInformation, Map<C,Boolean> written)
          Writes a cluster to the designated print stream.
protected  void writeHeader(PrintStream out, List<AttributeSettings> settings, List<String> headerInformation, C cluster)
          Writes a header for the specified cluster providing information concerning the underlying database and the specified parameter-settings.
 
Methods inherited from class de.lmu.ifi.dbs.elki.algorithm.result.AbstractResult
getDatabase, writeHeader
 
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, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CHILDREN

public static String CHILDREN
Indicating the children of a cluster in the string representation.


PARENTS

public static String PARENTS
Indicating the parents of a cluster in the string representation.


LEVEL

public static String LEVEL
Indicating the level of a cluster in the string representation.


LEVEL_INDEX

public static String LEVEL_INDEX
Indicating the index within the level of a cluster in the string representation.


rootClusters

private List<C extends HierarchicalCluster<C>> rootClusters
The root clusters.

Constructor Detail

HierarchicalClusters

public HierarchicalClusters(List<C> rootClusters,
                            Database<O> db)
Provides a result of a clustering algorithm that computes hierarchical clusters from a cluster order.

Parameters:
rootClusters - the root clusters
db - the database containing the objects of the clusters

HierarchicalClusters

public HierarchicalClusters(C rootCluster,
                            Database<O> db)
Provides a result of a clustering algorithm that computes hierarchical clusters from a cluster order.

Parameters:
rootCluster - the root cluster
db - the database containing the objects of the clusters
Method Detail

output

public void output(PrintStream outStream,
                   Normalization<O> normalization,
                   List<AttributeSettings> settings)
            throws UnableToComplyException
Writes the cluster order to the given stream.

Parameters:
outStream - the stream to write to
normalization - Normalization to restore original values according to, if this action is supported - may remain null.
settings - the settings to be written into the header, if this parameter is null, no header will be written
Throws:
UnableToComplyException - if any feature vector is not compatible with values initialized during normalization

output

public void output(File dir,
                   Normalization<O> normalization,
                   List<AttributeSettings> settings)
            throws UnableToComplyException
Description copied from interface: Result
Writes the clustering result to the given file. Clustering result implementations, which are likely to provide several clusters are supposed to use the filename as prefix for every file to create and to append a proper suffix. In case of occuring IOExceptions the output is expected to be given at the standard-out. Therefore this behaviour should be also achievable by giving a null-Object as parameter.

Specified by:
output in interface Result<O extends DatabaseObject>
Overrides:
output in class AbstractResult<O extends DatabaseObject>
Parameters:
dir - file, which designates the location to write the results, or which's name designates the prefix of any locations to write the results, or which could remain null to designate the standard-out as location for output.
normalization - Normalization to restore original values according to, if this action is supported - may remain null.
settings - the settings to be written into the header, if this parameter is null, no header will be written
Throws:
UnableToComplyException - if any feature vector is not compatible with values initialized during normalization
See Also:
Result.output(java.io.File,de.lmu.ifi.dbs.elki.normalization.Normalization,java.util.List)

write

private void write(C cluster,
                   File dir,
                   PrintStream out,
                   Normalization<O> normalization,
                   List<AttributeSettings> settings,
                   List<String> headerInformation,
                   Map<C,Boolean> written)
            throws NonNumericFeaturesException,
                   FileNotFoundException
Writes a cluster to the designated print stream.

Parameters:
cluster - the cluster to be written
dir - the directory where to write
normalization - a Normalization to restore original values for output - may remain null
settings - the settings to be written into the header
headerInformation - list of header informations (each entry written in a separate line
written - the already written clusters
Throws:
NonNumericFeaturesException - if feature vector is not compatible with values initialized during normalization
FileNotFoundException

getRootClusters

public final List<C> getRootClusters()
Returns the root clusters.

Returns:
the root clusters

writeHeader

protected void writeHeader(PrintStream out,
                           List<AttributeSettings> settings,
                           List<String> headerInformation,
                           C cluster)
Writes a header for the specified cluster providing information concerning the underlying database and the specified parameter-settings. Subclasses may need to overwrite this method.

Parameters:
out - the print stream where to write
settings - the settings to be written into the header
headerInformation - additional information to be printed in the header, each entry will be printed in one separate line
cluster - the cluster to write the header for

Release 0.1 (2008-07-10_1838)