78 this->DeleteNode(node->
GetLeft());
107 n = (
Node*)this->GetRoot();
108 if (n ==
NULL)
return 0 ;
113 if (this->GetLeftDaughter(n) !=
NULL){
114 countNodes += this->CountNodes( this->GetLeftDaughter(n) );
116 if (this->GetRightDaughter(n) !=
NULL) {
117 countNodes += this->CountNodes( this->GetRightDaughter(n) );
120 return fNNodes = countNodes;
128 this->GetRoot()->PrintRec(os);
129 os <<
"-1" << std::endl;
138 this->GetRoot()->AddXMLTo(bdt);
146 this->DeleteNode( fRoot );
150 fRoot->ReadXML(trnode, tmva_Version_Code);
152 this->SetTotalTreeDepth();
172 Node * currentNode = GetRoot();
176 currentNode=CreateNode();
177 SetRoot(currentNode);
183 this->SetTotalTreeDepth();
192 if (currentNode->
GetPos()==
'l') parent->
SetLeft(currentNode);
196 parent = currentNode;
198 currentNode = CreateNode();
217 n = (
Node*) this->GetRoot();
219 Log() <<
kFATAL <<
"SetTotalTreeDepth: started with undefined ROOT node" <<
Endl;
223 if (this->GetLeftDaughter(n) !=
NULL){
224 this->SetTotalTreeDepth( this->GetLeftDaughter(n) );
226 if (this->GetRightDaughter(n) !=
NULL) {
227 this->SetTotalTreeDepth( this->GetRightDaughter(n) );
229 if (n->
GetDepth() > this->GetTotalTreeDepth()) this->SetTotalTreeDepth(n->
GetDepth());
237 TTHREAD_TLS_DECL_ARG(
MsgLogger,logger,
"BinaryTree");
MsgLogger & Endl(MsgLogger &ml)
virtual void Read(std::istream &istr, UInt_t tmva_Version_Code=TMVA_VERSION_CODE)
Read the binary tree from an input stream.
virtual ~BinaryTree()
destructor (deletes the nodes and "events" if owned by the tree
virtual void SetRight(Node *r)
void DeleteNode(Node *)
protected, recursive, function used by the class destructor and when Pruning
virtual Bool_t ReadDataRecord(std::istream &, UInt_t tmva_Version_Code=TMVA_VERSION_CODE)=0
virtual void SetLeft(Node *l)
const std::string ClassName(PyObject *pyobj)
Retrieve the class name from the given python object (which may be just an instance of the class)...
void SetTotalTreeDepth(Int_t depth)
virtual void ReadXML(void *node, UInt_t tmva_Version_Code=TMVA_VERSION_CODE)
read attributes from XML
virtual void Print(std::ostream &os) const
recursively print the tree
std::ostream & operator<<(std::ostream &os, const BinaryTree &tree)
print the tree recursinvely using the << operator
std::istream & operator>>(std::istream &istr, BinaryTree &tree)
read the tree from an std::istream
virtual void SetParent(Node *p)
virtual Node * GetParent() const
virtual Node * GetRight() const
virtual void * AddXMLTo(void *parent) const
add attributes to XML
UInt_t CountNodes(Node *n=NULL)
return the number of nodes in the tree. (make a new count –> takes time)
Node * GetRightDaughter(Node *n)
get right daughter node current node "n"
Node * GetLeftDaughter(Node *n)
get left daughter node current node "n"
virtual Node * GetLeft() const