26 #ifndef ROOT_TMVA_NodekNN 27 #define ROOT_TMVA_NodekNN 94 void Print(std::ostream& os,
const std::string &offset =
"")
const;
182 return fEvent.GetWeight();
252 assert(
fMod == depth % event.GetNVar() &&
"Wrong recursive depth in Node<>::Add");
266 fNodeL =
new Node<T>(
this, event, (depth + 1) % event.GetNVar());
275 fNodeR =
new Node<T>(
this, event, (depth + 1) % event.GetNVar());
294 os << offset <<
"-----------------------------------------------------------" << std::endl;
295 os << offset <<
"Node: mod " <<
fMod 297 <<
" with weight: " <<
GetWeight() << std::endl
301 os << offset <<
"Has left node " << std::endl;
304 os << offset <<
"Has right node" << std::endl;
308 os << offset <<
"PrInt_t left node " << std::endl;
312 os << offset <<
"PrInt_t right node" << std::endl;
335 if (!node || nfind < 1) {
345 if (!nlist.empty()) {
347 max_dist = nlist.back().second;
349 if (nlist.size() == nfind) {
366 if (nlist.size() < nfind) {
369 else if (nlist.size() == nfind) {
370 if (distance < max_dist) {
376 std::cerr <<
"TMVA::kNN::Find() - logic error in recursive procedure" << std::endl;
383 typename std::list<std::pair<const Node<T> *,
Float_t> >::iterator lit = nlist.begin();
386 for (; lit != nlist.end(); ++lit) {
387 if (distance < lit->second) {
395 nlist.insert(lit, std::pair<
const Node<T> *,
Float_t>(node, distance));
444 if (!node || !(nfind < 0.0)) {
454 if (!nlist.empty()) {
456 max_dist = nlist.back().second;
458 if (!(ncurr < nfind)) {
477 else if (!nlist.empty()) {
478 if (distance < max_dist) {
483 std::cerr <<
"TMVA::kNN::Find() - logic error in recursive procedure" << std::endl;
493 typename std::list<std::pair<const Node<T> *,
Float_t> >::iterator lit = nlist.begin();
496 for (; lit != nlist.end(); ++lit) {
497 if (distance < lit->second) {
504 lit = nlist.insert(lit, std::pair<
const Node<T> *,
Float_t>(node, distance));
506 for (; lit != nlist.end(); ++lit) {
508 if (!(ncurr < nfind)) {
514 if(lit != nlist.end())
516 nlist.erase(lit, nlist.end());
524 count +=
Find(nlist, node->
GetNodeL(), event, nfind, ncurr);
525 count +=
Find(nlist, node->
GetNodeR(), event, nfind, ncurr);
528 count +=
Find(nlist, node->
GetNodeR(), event, nfind, ncurr);
529 count +=
Find(nlist, node->
GetNodeL(), event, nfind, ncurr);
534 count +=
Find(nlist, node->
GetNodeL(), event, nfind, ncurr);
537 count +=
Find(nlist, node->
GetNodeR(), event, nfind, ncurr);
const Node * GetNodeR() const
const Node * Add(const T &event, UInt_t depth)
This is Node member function that adds a new node to a binary tree.
UInt_t Depth(const Node< T > *node)
const Node & operator=(const Node &)
Float_t GetVarMin() const
void SetNodeL(Node *node)
const Node * GetNodeP() const
const Node * GetNodeL() const
Float_t GetVarMax() const
Double_t GetWeight() const
const T & GetEvent() const
UInt_t Find(std::list< std::pair< const Node< T > *, Float_t > > &nlist, const Node< T > *node, const T &event, UInt_t nfind)
Abstract ClassifierFactory template that handles arbitrary types.
void SetNodeR(Node *node)
Float_t GetVarDis() const