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

Node Class Reference

A node used in the evolving tree. More...

#include <node.hh>

List of all members.

Public Member Functions

 Node ()
 Basic constructor.
 Node (const Node &source)
 Copy constructor.
 ~Node ()
 Destructor.
double Distance (const double *sample) const
 Euclidean distance between prototype and sample.
double Distance (const Node &other) const
int GetParent () const
void SetParent (const int newparent)
const vector< int > & GetChildren () const
void SetChildren (const vector< int > newchildren)
void AddChild (int newchild)
void ClearChildren ()
int GetNumber () const
void SetNumber (int newnumber)
int GetDimension ()
const double * GetDataVector () const
 Get the data vector.
void SetDataVector (int ndim, const double *newvector)
 Assign a new data vector.
void SetDataVector (const double *newvector)
 Assign a new data vector.
void UpdateTowards (const double *targetvector, const double weight)
 Move towards the given vector.
double IncrementBMU ()
 Increment BMU count.
double BestMatches () const
void ClearBestMatches ()
void SetBestMatches (double bm)
void CopyDataFrom (const Node &source)
 Duplicate a state.
void PrintInTextForm (ostream &os)
 Prints the data vector.
Nodeoperator= (const Node &source)
 Assignment operator.
void PrintState (ostream &os) const
 Print state info.
void PrintProto (ostream &os) const
 A verbose description of the data vector.

Private Attributes

double * proto
 The prototype vector.
int dim
 Dimension of the prototype vector.
int mynumber
 This node's number (or index) in the tree.
int parent
 The parent's number in the tree.
vector< int > children
 Children's numbers, if any.
double bestmatches
 How many times this node has been the BMU.

Friends

ostream & operator<< (ostream &os, Node &outnode)
 Serializes the node.
istream & operator>> (istream &is, Node &innode)
 Creates a new node from binary stream.


Detailed Description

A node used in the evolving tree.

A simple node that forms a basis of the Evolving Tree. It only contains a prototype vector and knowledge of its parents and children.


Constructor & Destructor Documentation

Node::Node  ) 
 

Basic constructor.

Sets everything to zero.

Node::Node const Node source  ) 
 

Copy constructor.

Parameters:
source A node to be copied.

Node::~Node  ) 
 

Destructor.

Very basic, just unallocates the data vector.


Member Function Documentation

void Node::CopyDataFrom const Node source  ) 
 

Duplicate a state.

Duplicate the state of some other node to this one. Also copies the count numbers, so be careful not to shoot yourself in the foot with those.

Parameters:
source The source to copy data from.

double Node::Distance const double *  sample  )  const
 

Euclidean distance between prototype and sample.

Calculates the euclidian distance between the node and a given data vector.

Parameters:
sample A data vector, must have the same dimension as the node. (not checked)
Returns:
A double containing the distance.

const double * Node::GetDataVector  )  const
 

Get the data vector.

Returns a copy of the node's data vector.

Returns:
The data vector.

double Node::IncrementBMU  ) 
 

Increment BMU count.

Call this when the node has been selected as the BMU

Returns:
BMU count thus far, including the current one.

void Node::PrintInTextForm ostream &  os  ) 
 

Prints the data vector.

Prints the elements of the location vector to the stream. The elements are separated by a space and the line is ended by a linefeed. This function can be used, for example, exporting the nodes as Matlab matrices.

Parameters:
os The stream to write to.

void Node::PrintProto ostream &  os  )  const
 

A verbose description of the data vector.

Prints a free form description of the data vector.

Parameters:
os The stream to write to.

void Node::PrintState ostream &  os  )  const
 

Print state info.

Outputs the state of the node in plain text to the specified stream. Does not output prototype vector.

Parameters:
os The stream to write to.

void Node::SetDataVector const double *  newvector  ) 
 

Assign a new data vector.

Sets the node's data vector to a new one.

Parameters:
newvector The new vector, assumed to have the same size as the current vector.

void Node::SetDataVector int  ndim,
const double *  newvector
 

Assign a new data vector.

Replaces the node's data vector with a new one with the given dimension.

Parameters:
ndim The new dimension.
newvector The new data vector of size ndim.

void Node::UpdateTowards const double *  targetvector,
const double  weight
 

Move towards the given vector.

Updates the node towards the given data vector by the amount specified by weight. Currently implemented with the Kohonen rule.

Parameters:
targetvector The vector to update towards.
weight How much to update, should be between 0 and 1.


Friends And Related Function Documentation

ostream& operator<< ostream &  os,
Node outnode
[friend]
 

Serializes the node.

Writes the node to the given stream as a binary dump. The dump does not have any magic numbers or other identifiers.

Parameters:
os The stream to write to (usually a file).
outnode The node to serialize.
Returns:
The stream written to.

istream& operator>> istream &  is,
Node innode
[friend]
 

Creates a new node from binary stream.

Reads the binary stream and uses it to build a new node. No error checking of any kind is done, so make sure that the stream points to a sensible location.

Parameters:
is The stream to read (usually a file).
innode The node to write the information to.
Returns:
The stream just read.


The documentation for this class was generated from the following files:
Generated on Wed May 17 15:43:41 2006 for The Evolving Tree by  doxygen 1.4.1