52 TMVA::BinaryTree::BinaryTree(
void )
74 this->DeleteNode(node->
GetLeft());
103 n = (
Node*)this->GetRoot();
104 if (n ==
NULL)
return 0 ;
109 if (this->GetLeftDaughter(n) !=
NULL){
110 countNodes += this->CountNodes( this->GetLeftDaughter(n) );
112 if (this->GetRightDaughter(n) !=
NULL) {
113 countNodes += this->CountNodes( this->GetRightDaughter(n) );
116 return fNNodes = countNodes;
124 this->GetRoot()->PrintRec(os);
125 os <<
"-1" << std::endl;
134 this->GetRoot()->AddXMLTo(bdt);
142 this->DeleteNode( fRoot );
146 fRoot->ReadXML(trnode, tmva_Version_Code);
148 this->SetTotalTreeDepth();
168 Node * currentNode = GetRoot();
172 currentNode=CreateNode();
173 SetRoot(currentNode);
179 this->SetTotalTreeDepth();
188 if (currentNode->
GetPos()==
'l') parent->
SetLeft(currentNode);
192 parent = currentNode;
194 currentNode = CreateNode();
213 n = (
Node*) this->GetRoot();
215 Log() <<
kFATAL <<
"SetTotalTreeDepth: started with undefined ROOT node" <<
Endl;
219 if (this->GetLeftDaughter(n) !=
NULL){
220 this->SetTotalTreeDepth( this->GetLeftDaughter(n) );
222 if (this->GetRightDaughter(n) !=
NULL) {
223 this->SetTotalTreeDepth( this->GetRightDaughter(n) );
225 if (n->
GetDepth() > this->GetTotalTreeDepth()) this->SetTotalTreeDepth(n->
GetDepth());
233 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)...
ClassImp(TMVA::BinaryTree) TMVA
constructor for a yet "empty" tree. Needs to be filled afterwards
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)
Abstract ClassifierFactory template that handles arbitrary types.
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