00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
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
00094
00095 void PrintState(ostream &os) const;
00096 void PrintProto(ostream &os) const;
00097 };
00098
00099 #endif
00100
00101
00102
00103
00104