Main Page | Class List | File List | Class Members | File Members

node.hh

Go to the documentation of this file.
00001 /*
00002 The Evolving Tree
00003 Copyright (C) 2004 Jussi Pakkanen, Petri Turkulainen
00004 
00005 This program is free software; you can redistribute it and/or
00006 modify it under the terms of the GNU General Public License
00007 as published by the Free Software Foundation; either version 2
00008 of the License, or (at your option) any later version.
00009 
00010 This program is distributed in the hope that it will be useful,
00011 but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 GNU General Public License for more details.
00014 
00015 You should have received a copy of the GNU General Public License
00016 along with this program; if not, write to the Free Software
00017 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00018 */
00019 
00028 #ifndef _node_hh_
00029 #define _node_hh_
00030 
00031 #include<iostream>
00032 #include<fstream>
00033 #include<vector>
00034 #include<math.h>
00035 
00036 #include"etreedef.hh"
00037 
00045 class Node {
00046 
00047 private:
00048 
00049   double *proto; 
00050   int dim;       
00051 
00052   int mynumber;         
00053   int parent;           
00054   vector<int> children; 
00055 
00056   double bestmatches; 
00057 
00058 protected:
00059 
00060 public:
00061 
00062   Node();
00063   Node(const Node &source);
00064   ~Node();
00065   double Distance(const double *sample) const;
00066   double Distance(const Node &other) const { return Distance(other.proto); }
00067   int GetParent() const { return parent; }
00068   void SetParent(const int newparent) { parent = newparent; }
00069   const vector<int>& GetChildren() const { return children; }
00070   void SetChildren(const vector<int> newchildren) { children = newchildren; }
00071   void AddChild(int newchild) { children.push_back(newchild); }
00072   void ClearChildren() { children.clear(); }
00073   int GetNumber() const { return mynumber; }
00074   void SetNumber(int newnumber) { mynumber = newnumber; }
00075   int GetDimension() { return dim; }
00076 
00077   const double* GetDataVector() const;
00078   void SetDataVector(int ndim, const double* newvector);
00079   void SetDataVector(const double* newvector);
00080   void UpdateTowards(const double* targetvector, const double weight);
00081 
00082   double IncrementBMU();
00083   double BestMatches() const { return bestmatches; }
00084   void ClearBestMatches() { bestmatches = 0; }
00085   void SetBestMatches(double bm) { bestmatches = bm; } 
00086 
00087   void CopyDataFrom(const Node &source);
00088   void PrintInTextForm(ostream &os);
00089   Node& operator=(const Node &source);
00090   friend ostream& operator<<(ostream &os, Node &outnode);
00091   friend istream& operator>>(istream &is, Node &innode);
00092 
00093   // Functions that print the state of the node in human interpretable
00094   // form.
00095   void PrintState(ostream &os) const;
00096   void PrintProto(ostream &os) const;
00097 };
00098 
00099 #endif
00100 
00101 
00102 
00103 
00104 

Generated on Wed May 17 15:43:41 2006 for The Evolving Tree by  doxygen 1.4.1