HAPI::Node Class Reference

Nodes are one of the fundamental objects used in the construction of Bayesian networks and LIMIDs. More...

Inheritance diagram for HAPI::Node:
HAPI::ContinuousChanceNode HAPI::DiscreteNode HAPI::FunctionNode HAPI::InstanceNode HAPI::UtilityNode HAPI::DiscreteChanceNode HAPI::DiscreteDecisionNode HAPI::BooleanDCNode HAPI::IntervalDCNode HAPI::LabelledDCNode HAPI::NumberedDCNode HAPI::BooleanDDNode HAPI::IntervalDDNode HAPI::LabelledDDNode HAPI::NumberedDDNode

List of all members.

Public Member Functions

void addParent (Node *parent)
 Add parent as a new parent of this node.
void addToInputs ()
 Add this Node to the list of input nodes in this Class.
void addToOutputs ()
 Add this Node to the list of output nodes in this Class.
virtual Nodeclone () const =0
 Clone this Node object.
void deleteAttribute (const std::string &key)
 Delete the specified attribute from the attribute list of this Node.
void generateTable ()
 Generate the table for this Node as it is specified by the model (i.e., the expressions).
std::string getAttribute (const std::string &key) const
 Return the value associated with key in the attribute list of this node.
AttributeList getAttributes () const
 Returns a vector of attributes associated with this Node.
virtual Category getCategory () const =0
 Return the node category.
NodeList getChildren () const
 Return a NodeList containing the children of this node.
DomaingetDomain () const
 Return the Domain this Node belongs to.
Constraint getEdgeConstraint (Node *bNode) const
 Retrieve the learning constraint specified for the edge.
ClassgetHomeClass () const
 Get the class in which this node is placed.
DomaingetHomeDomain () const
 Get the Domain in which this node is placed.
NodegetInstance () const
 Returns the InstanceNode containing this (cloned) output node.
JunctionTreegetJunctionTree () const
 Return the JunctionTree to which this node belongs.
virtual Kind getKind () const =0
 Return the node kind.
std::string getLabel () const
 Get the label of this node.
NodegetMaster () const
 Returns the "master" of this (cloned) output Node of an InstanceNode (i.e., the Node cloned to get this output Node).
ModelgetModel () const
 Return the Model of this Node.
std::string getName ()
 Retrieve the name of this Node.
NodeList getParents () const
 Return a NodeList containing the parents of this node.
std::pair< int, int > getPosition () const
 Return the position of the node.
NodeList getSource () const
 Returns a NodeList of Class nodes that identifies this Domain node.
TablegetTable ()
 Return the table associated with this Node.
void * getUserData () const
 Return the value stored within the user data slot of this node.
bool hasAttribute (const std::string &key) const
 Test if this Node has an attribute with the specified key.
void removeFromInputs ()
 Remove this Node from the list of input nodes in the Class.
void removeFromOutputs ()
 Remove this Node from the list of output nodes in the Class.
void removeParent (Node *parent)
 Remove the directed link between parent and this node.
void setAttribute (const std::string &key, const std::string &value)
 Insert the key/value pair in the attribute list of this Node.
void setEdgeConstraint (Node *bNode, Constraint C)
 Specify constraint for the edge.
void setLabel (const std::string &label)
 Set the node label.
void setLabel (const char *label)
 Set the node label.
void setName (const std::string &name)
 Create a copy of name and assign it to this node.
void setName (const char *name)
 Create a copy of name and assign it to this node.
void setPosition (const std::pair< int, int > &pos)
 Set the position of the node.
void setPosition (int x, int y)
 Set the position of the node.
void setUserData (void *data)
 The Hugin API provides a data slot within each Node object.
void switchParent (Node *oldParent, Node *newParent)
 Substitute a new parent for an old parent.
virtual ~Node () throw ()
 Delete Node.

Detailed Description

Nodes are one of the fundamental objects used in the construction of Bayesian networks and LIMIDs.

All nodes need a NetworkModel (i.e., a Class or a Domain); that is, the network must exist before its nodes can be created.


Constructor & Destructor Documentation

virtual HAPI::Node::~Node (  )  throw () [virtual]

Delete Node.

The node is deleted from its domain. If the domain was compiled, the corresponding compiled structure is deleted. All references and pointers to the node become invalid.


Member Function Documentation

void HAPI::Node::addParent ( Node parent  ) 

Add parent as a new parent of this node.

That is, add a directed link from parent to this node.

void HAPI::Node::addToInputs (  ) 

Add this Node to the list of input nodes in this Class.

I.e., make this Node an input node.

void HAPI::Node::addToOutputs (  ) 

Add this Node to the list of output nodes in this Class.

I.e., make this Node an output node.

virtual Node* HAPI::Node::clone (  )  const [pure virtual]
void HAPI::Node::deleteAttribute ( const std::string &  key  ) 

Delete the specified attribute from the attribute list of this Node.

If the key doesn't exist, no action is taken.

void HAPI::Node::generateTable (  ) 

Generate the table for this Node as it is specified by the model (i.e., the expressions).

If one or more expressions are illegal in one way or the other, an expression is thrown.

std::string HAPI::Node::getAttribute ( const std::string &  key  )  const

Return the value associated with key in the attribute list of this node.

Returns:
string containing the attribute value.
Domain* HAPI::Node::getDomain (  )  const

Return the Domain this Node belongs to.

This Node must reside in an existing Hugin domain.

Returns:
A pointer to the Domain where this Node resides.
Domain* HAPI::Node::getHomeDomain (  )  const

Get the Domain in which this node is placed.

This function is equivalent to getDomain, and is only here for consistency with getHomeClass.

Node* HAPI::Node::getInstance (  )  const

Returns the InstanceNode containing this (cloned) output node.

Note that we clone all output nodes when we create an InstanceNode. This is done in order to make it possible to specify conditional probability tables involving output nodes from InstanceNode's.

Returns:
The InstanceNode containing this output clone.
See also:
InstanceNode
Node* HAPI::Node::getMaster (  )  const

Returns the "master" of this (cloned) output Node of an InstanceNode (i.e., the Node cloned to get this output Node).

Note that "master" belongs to another Class object. Note also that we clone all output nodes when we create an InstanceNode. This is done in order to make it possible to specify conditional probability tables involving output nodes from InstanceNode's.

Returns:
The "master" of this output clone.
std::string HAPI::Node::getName (  ) 

Retrieve the name of this Node.

If this node has not previously been assigned a name, a valid name will automatically be assigned.

Returns:
A string containing the name of this node.
NodeList HAPI::Node::getSource (  )  const

Returns a NodeList of Class nodes that identifies this Domain node.

The createDomain method of the Class class unfolds an object-oriented (nested) specification of a Bayesian network or a LIMID into a regular Domain object.

Nodes in this Domain which originates from nodes residing in nested sub-networks (via InstanceNodes) can be uniquely related to a sequence of InstanceNodes and an ordinary Node of the object-oriented network.

Returns:
An ordered NodeList with the InstanceNodes and the ordinary Node identifying the source of this Node that must belong to a Domain.
Table* HAPI::Node::getTable (  ) 

Return the table associated with this Node.

If the node is a DiscreteChanceNode, the table is the conditional probability table for the node given its parents.

If the node is a UtilityNode, the table represents a utility function of the parents of the node.

void* HAPI::Node::getUserData (  )  const [inline]

Return the value stored within the user data slot of this node.

If the stored value is NULL, or if no value has been stored, NULL is returned. It is the responsibility of the application programmer to ensure that the data is valid, that pointers are accessed correctly, etc. Also note that when you delete a node, Hugin does not attempt to delete the data pointed to by the user data slot. It is the responsibility of the user.

void HAPI::Node::removeFromInputs (  ) 

Remove this Node from the list of input nodes in the Class.

I.e., make this Node an ordinary node again.

void HAPI::Node::removeFromOutputs (  ) 

Remove this Node from the list of output nodes in the Class.

I.e., make this Node an ordinary node again.

void HAPI::Node::removeParent ( Node parent  ) 

Remove the directed link between parent and this node.

The table (if any) is updated such that the updated table contains the portion of the old table that corresponds to parent being in its first state (if parent is discrete).

Parameters:
parent Pointer to the parent Node that will be removed.
void HAPI::Node::setAttribute ( const std::string &  key,
const std::string &  value 
)

Insert the key/value pair in the attribute list of this Node.

If the key is already defined, the value is updated.

void HAPI::Node::setName ( const std::string &  name  ) 

Create a copy of name and assign it to this node.

name must be a valid name, i.e., it must follow the rules that govern the validity of C identifiers, and no other node in the domain to which *this node belongs can have the same name.

Parameters:
name the desired name of the node.
void HAPI::Node::setName ( const char *  name  ) 

Create a copy of name and assign it to this node.

name must be a valid name, i.e., it must follow the rules that govern the validity of C identifiers, and no other node in the domain to which *this node belongs can have the same name.

Parameters:
name A pointer to a zero-terminated string containing the desired name of the node.
void HAPI::Node::setPosition ( int  x,
int  y 
)

Set the position of the node.

Parameters:
x The desired x coordinate of the node.
y The desired y coordinate of the node.
void HAPI::Node::setUserData ( void *  data  )  [inline]

The Hugin API provides a data slot within each Node object.

This data slot is for use exclusively by the user/application. This slot can hold a pointer to arbitrary data, such as a file, a display window, an input buffer from hardware sensors, etc. Please note that Hugin does not do anything to the user data. Data is not even copied. Only the pointer to the data is stored.

Parameters:
data Pointer to user-defined data associated with this node.
void HAPI::Node::switchParent ( Node oldParent,
Node newParent 
)

Substitute a new parent for an old parent.

The new parent must be compatible with the old parent: This implies that it must be of the same class, have the same number of states, etc.


Copyright Hugin Expert A/S 1993-2010