1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
|
/*
* treenode.cpp
* Mothur
*
* Created by Sarah Westcott on 1/23/09.
* Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
*
*/
#include "treenode.h"
/****************************************************************/
Node::Node() {
m = MothurOut::getInstance();
//initialize node
name = "";
branchLength = -1;
parent = -1;
lchild = -1;
rchild = -1;
length2leaf = 0.0;
label = "";
}
/****************************************************************/
void Node::setName(string Name) { name = Name; }
/****************************************************************/
void Node::setGroup(vector<string> groups) { group =groups; }
/****************************************************************/
void Node::setBranchLength(float l) { branchLength = l; }
/****************************************************************/
void Node::setLabel(string l) { label = l; }
/****************************************************************/
void Node::setLengthToLeaves(float l) { length2leaf = l; }
/****************************************************************/
void Node::setParent(int p) { parent = p; }
/****************************************************************/
void Node::setIndex(int i) { vectorIndex = i; }
/****************************************************************/
void Node::setChildren(int lc, int rc) { lchild = lc; rchild = rc; } //leftchild, rightchild
/****************************************************************/
string Node::getName() { return name; }
/****************************************************************/
vector<string> Node::getGroup() { return group; }
/****************************************************************/
float Node::getBranchLength() { return branchLength; }
/****************************************************************/
string Node::getLabel() { return label; }
/****************************************************************/
float Node::getLengthToLeaves() { return length2leaf; }
/****************************************************************/
int Node::getParent() { return parent; }
/****************************************************************/
int Node::getLChild() { return lchild; }
/****************************************************************/
int Node::getRChild() { return rchild; }
/****************************************************************/
int Node::getIndex() { return vectorIndex; }
/****************************************************************/
//to be used by printTree in the Tree class to print the leaf info
void Node::printNode() {
try{
m->mothurOut(name + " " + toString(parent) + " " + toString(lchild) + " " + toString(rchild) + " \n");
}
catch(exception& e) {
m->errorOut(e, "Node", "printNode");
exit(1);
}
}
/****************************************************************/
|