org.peace_tools.data
Class MSTNode

java.lang.Object
  extended by org.peace_tools.data.MSTNode

public class MSTNode
extends java.lang.Object

A class that represents a single node in a Minimum Spanning Tree (MST). This class is a pure data class that is used to encapsulate the information pertaining to a node on a Minimum Spanning Tree (MST). This class is a self-referential structure, in that the child nodes of this class are MSTNode objects. This definition permits a MSTNode to contain a complete sub-tree as a part of it. The MSTNode objects are created and used by the MST class that represents the top-level MST.


Field Summary
(package private)  int alignmentMetric
          The alignment metric generated by a given EST analyzer indicating some of the alignment relationship between this node and its parent node.
private  java.util.ArrayList<MSTNode> childNodes
          This array list contains the list of child nodes for this node.
(package private)  int estIdx
          The zero-based index of the EST that a given MST node represents.
(package private)  float metric
          The similarity/distance metric generated by a given EST analyzer indicating the relationship between this node and its parent node.
private  MSTNode parent
          The parent node for this MSTNode.
 
Constructor Summary
MSTNode(MSTNode parent, int estIndex, float nodeMetric, int alignment)
          Constructor to create a MSTNode.
 
Method Summary
 void addChild(MSTNode node)
          Add another MSTNode as the child node of this node.
 int getAlignmentMetric()
          Returns the distance metric value set for this node.
 java.util.ArrayList<MSTNode> getChildren()
          Obtain the child nodes for this node.
 int getESTIndex()
          Obtain the index of the EST associated with this node.
 float getMetric()
          Returns the metric value set for this node.
 boolean isLeaf()
          Determine if this node is a leaf node that has no child nodes.
 boolean isRoot()
          Determine if this node is the root node.
 void print(java.io.PrintStream out, MSTNode node, java.lang.String indent)
          Method to recursively print the information that is stored in this node.
 java.lang.String toString()
          This method returns the EST index and metric as a string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

parent

private MSTNode parent
The parent node for this MSTNode. If this MSTNode is the root node then it has no parent (that is parent is null).


childNodes

private java.util.ArrayList<MSTNode> childNodes
This array list contains the list of child nodes for this node.


estIdx

int estIdx
The zero-based index of the EST that a given MST node represents. This value is the index of the corresponding EST in the list of ESTs in the ESTFile associated with this MST.


metric

float metric
The similarity/distance metric generated by a given EST analyzer indicating the relationship between this node and its parent node.


alignmentMetric

int alignmentMetric
The alignment metric generated by a given EST analyzer indicating some of the alignment relationship between this node and its parent node.

Constructor Detail

MSTNode

public MSTNode(MSTNode parent,
               int estIndex,
               float nodeMetric,
               int alignment)
Constructor to create a MSTNode. This constructor provides a convenient mechanism to create and initialize an MSTNode object with necessary information.

Parameters:
parent - The parent node for this MST. If this node is the root node in the MST, then this parameter can be null.
estIndex - The index of the EST. This value must be the index of the corresponding EST in the list of ESTs in the ESTList associated with the MST in which this node is present.
nodeMetric - The similarity/distance metric between this EST and its parent EST.
alignment - The alignment metric generated by a given EST analyzer indicating some of the alignment relationship between this node and its parent node.
Method Detail

addChild

public void addChild(MSTNode node)
Add another MSTNode as the child node of this node. This method adds the given node as a child node. In addition it also sets up the parent reference in the child to point to this node.

Parameters:
node - The node to be added as a direct child of this node.

isRoot

public boolean isRoot()
Determine if this node is the root node.

Note: This method is meaningful only after a complete MST has been built.

Returns:
This method returns true if the parent of this node is null, indicating this is a root node.

isLeaf

public boolean isLeaf()
Determine if this node is a leaf node that has no child nodes.

Note: This method is meaningful only after a complete MST has been built.

Returns:
This method returns true if this node has no children.

getMetric

public float getMetric()
Returns the metric value set for this node. This method returns the metric value for this node when the node was instantiated.

Returns:
The metric value set for this node.

getAlignmentMetric

public int getAlignmentMetric()
Returns the distance metric value set for this node. This method returns the distance metric value for this node when\ the node was instantiated.

Returns:
The distance metric value set for this node.

getESTIndex

public int getESTIndex()
Obtain the index of the EST associated with this node.

Returns:
The zero-based index of the EST that this node represents. This value is the index of the corresponding EST in the list of ESTs in the ESTFile associated with this MST.

toString

public java.lang.String toString()
This method returns the EST index and metric as a string.

Overrides:
toString in class java.lang.Object
Returns:
This method returns a simple string representation of the data stored in this MSTNode.

print

public void print(java.io.PrintStream out,
                  MSTNode node,
                  java.lang.String indent)
Method to recursively print the information that is stored in this node. This method recursively prints the child nodes. This method provides a convenient mechanism to validate the data stored in this node.

Parameters:
out - The output stream to which the data is to be serialized.
node - The node to
indent - The number of spaces to be used to indent the output.

getChildren

public java.util.ArrayList<MSTNode> getChildren()
Obtain the child nodes for this node. This method can be used to obtain the child nodes associated with this MST node. If the nodes do not have any children then this method returns null.

Returns:
This method returns the array list containing the list of nodes associated with this MST node.