Class to represent a Minimum Spanning Tree (MST). More...
#include <MST.h>
Public Member Functions | |
MST (const int maxNodes, const bool haveAlignmentMetric) | |
The constructor. | |
~MST () | |
The destructor. | |
bool | hasAlignmentMetric () const |
Determine if nodes in this MST have alignment metric values. | |
void | addNode (const int parentIdx, const int estIdx, const float similarity, const int alignmentInfo, const int directionInfo) |
Convenience method to add a MSTNode to the EST. | |
NodeList & | getNodes () |
Obtain a mutable list of nodes in this MST. | |
void | serialize (const char *fileName, const char *srcFile, const float threshold) const |
Helper method to write MST data to a given file. | |
float | getMSTDistance () const |
Obtain the total distance of this MST. | |
Static Public Member Functions | |
static MST * | deSerialize (const char *fileName) |
Method to create and load data for MST from a text file. | |
Private Attributes | |
NodeList | nodeList |
The list of nodes in this MST. | |
bool | haveAlignmentMetric |
Instance variable to indicate if alignment metric in nodes is valid. | |
Friends | |
std::ostream & | operator<< (std::ostream &, const MST &) |
Class to represent a Minimum Spanning Tree (MST).
This class is used to represent a MST that is built by the MSTClusterMaker. It essentially maintains a vector of MSTNode objects. The order of nodes in the MST reflects the order in which nodes were added to create the tree. Refer to the documentation on the MSTNode class for details on the data encapsulated by it.
Definition at line 58 of file MST.h.
MST::MST | ( | const int | maxNodes, | |
const bool | haveAlignmentMetric | |||
) |
The constructor.
The default constructor for the MST. The constructor performs no special operations and is present merely to adhere to coding conventions.
[in] | maxNodes | The number of nodes for which space must be initially reserved. Reserving space reduces the number of times the MST has to reallocate memory as nodes are added to it. |
[in] | haveAlignmentMetric | If this value is true , then that indicates that this MST also includes additional alignment information with each node in the MST. |
Definition at line 43 of file MST.cpp.
References nodeList.
Referenced by deSerialize().
MST::~MST | ( | ) | [inline] |
void MST::addNode | ( | const int | parentIdx, | |
const int | estIdx, | |||
const float | similarity, | |||
const int | alignmentInfo, | |||
const int | directionInfo | |||
) |
Convenience method to add a MSTNode to the EST.
This method may be used to append a node to the EST. The first node to be added must be root node (with parentIndex set to -1). This method performs no special checks to verify the integrity of the data.
[in] | parentIdx | The index of the parent EST for this Node. If a parent does not exist, then this value should be -1. |
[in] | estIdx | The index of the EST. This value must be the index of the corresponding EST in the list of ESTs returned by EST::getESTList() method. |
[in] | similarity | The similarity metric between this EST and its parent EST. |
[in] | alignmentInfo | Additional alignment information between the parentIdx and the estIdx to be stored in this node. |
[in] | directionInfo | Additional direction information between the parentIdx and the estIdx to be stored in this node. |
Definition at line 51 of file MST.cpp.
References nodeList.
Referenced by PMSTClusterMaker::addMoreChildESTs(), MSTClusterMaker::addMoreChildESTs(), PMSTClusterMaker::manager(), MSTClusterMaker::manager(), and PMSTClusterMaker::mergeManager().
MST * MST::deSerialize | ( | const char * | fileName | ) | [static] |
Method to create and load data for MST from a text file.
This method creates an MST and populates it with node data from a given text file. The text file must have been created through an earlier call to the serialize() method. If the MST was successfully populated then this method returns a pointer to the newly created MST. On errors this method returns NULL.
[in] | fileName | The text file from which the data for the MST must be read. |
Definition at line 91 of file MST.cpp.
References MSTNode::deSerialize(), haveAlignmentMetric, MST(), and nodeList.
Referenced by PMSTClusterMaker::makeClusters(), and MSTClusterMaker::populateMST().
float MST::getMSTDistance | ( | ) | const |
Obtain the total distance of this MST.
This method can be used to determine the total distance of the MST. This method iterates over all the nodes present in the MST and adds the distance/similarity metric together. It then returns the total.
Definition at line 125 of file MST.cpp.
References nodeList.
Referenced by serialize().
NodeList& MST::getNodes | ( | ) | [inline] |
Obtain a mutable list of nodes in this MST.
This method can be used to obtain a mutable list of nodes in contained by this MST.
Definition at line 134 of file MST.h.
References nodeList.
Referenced by MSTClusterMaker::buildAndShowClusters(), PMSTClusterMaker::mergeManager(), and PMSTClusterMaker::mergeWorker().
bool MST::hasAlignmentMetric | ( | ) | const [inline] |
void MST::serialize | ( | const char * | fileName, | |
const char * | srcFile, | |||
const float | threshold | |||
) | const |
Helper method to write MST data to a given file.
This method is a helper method that is used to write MST data to a given output file. This method is typically called from the makeClusters() method after MST construction has been completed.
[in] | fileName | The file to which the MST data is to be written. |
[in] | srcFile | The source file from where the ESTs were read. This file name is simply used for cross reference in the data generated for this MST. |
[in] | threshold | The threshold value to be used in clustering of the MST data. Important for downstream analysis such as that done by assembly tools. |
Definition at line 59 of file MST.cpp.
References arg_parser::get_global_args(), getMSTDistance(), getTime(), getTimeStamp(), haveAlignmentMetric, and nodeList.
Referenced by PMSTClusterMaker::makeClusters(), and MSTClusterMaker::makeClusters().
std::ostream& operator<< | ( | std::ostream & | , | |
const MST & | ||||
) | [friend] |
bool MST::haveAlignmentMetric [private] |
Instance variable to indicate if alignment metric in nodes is valid.
This instance variable is initialized when this MST is created. If this instance variable is true
then each Node in this MST has a valid alignment information.
Definition at line 202 of file MST.h.
Referenced by deSerialize(), and serialize().
NodeList MST::nodeList [private] |
The list of nodes in this MST.
This vector is used to track the set of nodes added to this minimum spanning tree. The maximum nodes in the tree is typically set in the constructor. Nodes are added via the addNode() method in this class.
Definition at line 193 of file MST.h.
Referenced by addNode(), deSerialize(), getMSTDistance(), getNodes(), MST(), operator<<(), and serialize().