org.knime.base.node.mine.cluster.hierarchical
Class ClusterNode

java.lang.Object
  extended by org.knime.base.node.mine.cluster.hierarchical.ClusterNode
All Implemented Interfaces:
DendrogramNode

public class ClusterNode
extends Object
implements DendrogramNode

Represents a Node in the hierarchy tree (Dendrogram) of a hierarchical clustering.

Author:
Christoph Sieb, University of Konstanz

Constructor Summary
ClusterNode(ClusterNode node1, ClusterNode node2, double dist)
          Constructs a new parent node from two child nodes.
ClusterNode(DataRow row, int rowIdx)
          Constructs a new leaf node from a data row.
 
Method Summary
 DataRow[] getAllDataRows()
          Returns all data row (leaf nodes) this sub tree.
 double getDist()
          Returns the distance between the two children nodes on the next level.
 ClusterNode getFirstSubnode()
          Returns the first sub-node of this node.
 int getLeafCount()
          Returns the number of leaf nodes contained in this node.
 DataRow getLeafDataPoint()
          Returns the DataRow associated with a leaf node.
 double getMaxDistance()
          Returns the maximum distance from this node to any of the leafs.
 int getRowIndex()
          Returns the index of the row stored inside this leaf node.
 ClusterNode getSecondSubnode()
          Returns the second sub-node of this node.
 boolean isLeaf()
          Returns if this node is a leaf.
 Iterable<ClusterNode> leafs()
          Returns an Iterable over all leaf nodes contained in this node.
static ClusterNode loadFromXML(NodeSettingsRO settings, DataArray orgTable)
          Loads a cluster node from the settings.
 void saveToXML(NodeSettingsWO settings)
          Saves the tree structure into the config.
 String toString()
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ClusterNode

public ClusterNode(DataRow row,
                   int rowIdx)
Constructs a new leaf node from a data row.

Parameters:
row - data row to create a node for
rowIdx - the row index for later reconstruction in load/save internals.

ClusterNode

public ClusterNode(ClusterNode node1,
                   ClusterNode node2,
                   double dist)
Constructs a new parent node from two child nodes.

Parameters:
node1 - the first node to create a parent node for
node2 - the second node to create a parent node for
dist - the distance to the node.
Method Detail

getRowIndex

public int getRowIndex()
Returns the index of the row stored inside this leaf node.

Returns:
the index of the row if the node is a leaf node -1 otherwise.

getAllDataRows

public DataRow[] getAllDataRows()
Returns all data row (leaf nodes) this sub tree.

Returns:
the array of data rows which are included in this sub tree.

leafs

public Iterable<ClusterNode> leafs()
Returns an Iterable over all leaf nodes contained in this node.

Returns:
an iterable over leaf nodes

getLeafCount

public int getLeafCount()
Returns the number of leaf nodes contained in this node. Leaf nodes return 1 by definition.

Returns:
the number of leaf nodes

getFirstSubnode

public ClusterNode getFirstSubnode()
Returns the first sub-node of this node. This method is implemented because of the binary characteristic of this tree.

Specified by:
getFirstSubnode in interface DendrogramNode
Returns:
the first sub node

getDist

public double getDist()
Returns the distance between the two children nodes on the next level. Must return 0 for leaf nodes.

Specified by:
getDist in interface DendrogramNode
Returns:
the distance to the next level.

isLeaf

public boolean isLeaf()
Returns if this node is a leaf.

Specified by:
isLeaf in interface DendrogramNode
Returns:
true if the node is a leaf node, false otherwise

getMaxDistance

public double getMaxDistance()
Returns the maximum distance from this node to any of the leafs. Must be 0 for leaf nodes.

Specified by:
getMaxDistance in interface DendrogramNode
Returns:
the maximum distance to a leaf node

getLeafDataPoint

public DataRow getLeafDataPoint()
Returns the DataRow associated with a leaf node.

Specified by:
getLeafDataPoint in interface DendrogramNode
Returns:
the leaf data point or null if this node is not a leaf

getSecondSubnode

public ClusterNode getSecondSubnode()
Returns the second sub-node of this node. This method is implemented because of the binary characteristic of this tree.

Specified by:
getSecondSubnode in interface DendrogramNode
Returns:
the second sub node

toString

public String toString()

Overrides:
toString in class Object

saveToXML

public void saveToXML(NodeSettingsWO settings)
Saves the tree structure into the config. Stores the distance, the rowy key (if its a leaf) and the left and right child.

Parameters:
settings - the config to save to.

loadFromXML

public static ClusterNode loadFromXML(NodeSettingsRO settings,
                                      DataArray orgTable)
                               throws InvalidSettingsException
Loads a cluster node from the settings.

Parameters:
settings - the config to load from
orgTable - the original table containing the rows in the same order!
Returns:
a cluster node
Throws:
InvalidSettingsException - if not stored properly.


Copyright, 2003 - 2010. All rights reserved.
University of Konstanz, Germany.
Chair for Bioinformatics and Information Mining, Prof. Dr. Michael R. Berthold.
You may not modify, publish, transmit, transfer or sell, reproduce, create derivative works from, distribute, perform, display, or in any way exploit any of the content, in whole or in part, except as otherwise expressly permitted in writing by the copyright owner or as specified in the license file distributed with this product.