libeblearn
ebl::class_node< Tlabel > Class Template Reference

#include <datasource.h>

List of all members.

Public Member Functions

 class_node (Tlabel id, string &name)
virtual ~class_node ()
 Destructor.
virtual bool empty ()
virtual bool internally_empty ()
 Returns false if this node contains at least 1 sample, true otherwise.
virtual intg next ()
virtual void add_child (class_node *child)
virtual void add_sample (intg index)
 Add a sample index to this node, i.e. this sample has the same label.
virtual intg nsamples ()
 Returns the number of samples contained in this node.
virtual Tlabel label ()
 Returns node label.
virtual Tlabel label (uint depth)
virtual uint depth ()
 Returns the depth of this node.
virtual uint set_depth (uint d)
virtual string & name ()
 Returns the name of this node.
virtual class_node< Tlabel > * get_parent ()
 Returns the parent pointer (NULL if no parent).
virtual bool is_parent (Tlabel lab)
 Returns true if label 'lab' is a parent of this node.

Protected Member Functions

virtual void set_non_empty ()
virtual void set_parent (class_node *parent)
 Set the parent to 'parent'.

Protected Attributes

Tlabel _label
 This class' label.
string & _name
class_nodeparent
 Parent node.
vector< class_node< Tlabel > * > children
 Children nodes.
vector< class_node< Tlabel >
* >::iterator 
it_children
bool bempty
 This node or its children have samples or not.
bool iempty
 This node has internal samples or not.
uint _depth
 Depth of this node.
vector< intg > samples
 Sample ids with this label.
vector< intg >::iterator it_samples
 Iterator in this class' samples.

Friends

class hierarchy_datasource

Detailed Description

template<typename Tlabel>
class ebl::class_node< Tlabel >

class_node A node class describing a class hierarchy. This class allows recursive balanced selection of samples.


Constructor & Destructor Documentation

template<typename Tlabel >
ebl::class_node< Tlabel >::class_node ( Tlabel  id,
string &  name_ 
)

Construct a class_node with label 'id'. Call set_parent() to establish parent relationship.

class_node


Member Function Documentation

template<typename Tlabel >
void ebl::class_node< Tlabel >::add_child ( class_node< Tlabel > *  child) [virtual]

Add 'child' to the vector of children and check that child's parent is indeed this node.

template<typename Tlabel >
bool ebl::class_node< Tlabel >::empty ( ) [virtual]

Returns false if this node or its children contain at least 1 sample, true otherwise. If false, next() can be called.

template<typename Tlabel >
Tlabel ebl::class_node< Tlabel >::label ( uint  depth) [inline, virtual]

Returns node label at depth 'depth'. If node has lower depth than d, this returns its leaf label.

template<typename Tlabel >
intg ebl::class_node< Tlabel >::next ( ) [virtual]

This returns the index of the next sample of this class in a balanced way, i.e. it will alternate between each direct children and itself. e.g. if this class id is 1, and has 3 children with ids 2,3,4, samples classes id will have this order: 1,2,3,4,1,2,3,4,1,etc.

template<typename Tlabel >
uint ebl::class_node< Tlabel >::set_depth ( uint  d) [virtual]

Set the depth of this node to d, and recursively set depth of children with d + 1, and return the maximum depth of all children.

template<typename Tlabel >
void ebl::class_node< Tlabel >::set_non_empty ( ) [protected, virtual]

Set this node to non-empty. This can be called by children when they receive samples, so that the information propagates back to the top. Later, parents know if they can attempt to get samples from their children or not.


The documentation for this class was generated from the following files: