67 this->DeleteNode( fRoot );
77 this->DeleteNode(node->
GetLeft());
106 n = (
Node*)this->GetRoot();
107 if (
n == NULL)
return 0 ;
112 if (this->GetLeftDaughter(
n) != NULL){
113 countNodes += this->CountNodes( this->GetLeftDaughter(
n) );
115 if (this->GetRightDaughter(
n) != NULL) {
116 countNodes += this->CountNodes( this->GetRightDaughter(
n) );
119 return fNNodes = countNodes;
127 this->GetRoot()->PrintRec(os);
128 os <<
"-1" << std::endl;
137 this->GetRoot()->AddXMLTo(bdt);
145 this->DeleteNode( fRoot );
149 fRoot->ReadXML(trnode, tmva_Version_Code);
151 this->SetTotalTreeDepth();
171 Node * currentNode = GetRoot();
175 currentNode=CreateNode();
176 SetRoot(currentNode);
182 this->SetTotalTreeDepth();
191 if (currentNode->
GetPos()==
'l') parent->
SetLeft(currentNode);
195 parent = currentNode;
197 currentNode = CreateNode();
216 n = (
Node*) this->GetRoot();
218 Log() << kFATAL <<
"SetTotalTreeDepth: started with undefined ROOT node" <<
Endl;
222 if (this->GetLeftDaughter(
n) != NULL){
223 this->SetTotalTreeDepth( this->GetLeftDaughter(
n) );
225 if (this->GetRightDaughter(
n) != NULL) {
226 this->SetTotalTreeDepth( this->GetRightDaughter(
n) );
228 if (
n->GetDepth() > this->GetTotalTreeDepth()) this->SetTotalTreeDepth(
n->GetDepth());
236 TTHREAD_TLS_DECL_ARG(
MsgLogger,logger,
"BinaryTree");
Base class for BinarySearch and Decision Trees.
UInt_t CountNodes(Node *n=nullptr)
return the number of nodes in the tree. (make a new count --> takes time)
Node * GetLeftDaughter(Node *n)
get left daughter node current node "n"
Node * GetRightDaughter(Node *n)
get right daughter node current node "n"
virtual void * AddXMLTo(void *parent) const
add attributes to XML
BinaryTree(void)
constructor for a yet "empty" tree. Needs to be filled afterwards
void DeleteNode(Node *)
protected, recursive, function used by the class destructor and when Pruning
void SetTotalTreeDepth(Int_t depth)
virtual void Print(std::ostream &os) const
recursively print the tree
virtual ~BinaryTree()
destructor (deletes the nodes and "events" if owned by the tree
virtual void ReadXML(void *node, UInt_t tmva_Version_Code=262657)
read attributes from XML
virtual void Read(std::istream &istr, UInt_t tmva_Version_Code=262657)
Read the binary tree from an input stream.
ostringstream derivative to redirect and format output
Node for the BinarySearch or Decision Trees.
virtual Node * GetLeft() const
virtual Node * GetParent() const
virtual void SetRight(Node *r)
virtual void SetLeft(Node *l)
virtual void SetParent(Node *p)
virtual Bool_t ReadDataRecord(std::istream &, UInt_t tmva_Version_Code=262657)=0
virtual Node * GetRight() const
std::istream & operator>>(std::istream &istr, BinaryTree &tree)
std::ostream & operator<<(std::ostream &os, const BinaryTree &tree)
MsgLogger & Endl(MsgLogger &ml)