COM.hugin.HAPI
Class Node

java.lang.Object
  |
  +--COM.hugin.HAPI.Node
Direct Known Subclasses:
ContinuousChanceNode, DiscreteChanceNode, DiscreteDecisionNode, InstanceNode, UtilityNode

public class Node
extends java.lang.Object

Nodes are one of the fundamental objects used in the construction of Bayesian networks and influence diagrams. All nodes need a NetworkModel (i.e., Class or Domain); that is, the network must exist before its nodes can be created.


Method Summary
 void addParent(Node newParent)
          Adds a node as a new parent of this Node.
 void addToInputs()
          Makes this Node become an input node of its Class.
 void addToOutputs()
          Makes this Node become an output node of its Class.
 void delete()
          Deletes this Node.
 boolean evidenceIsEntered()
          Returns 'true' if the evidence potential, currently registered with this Node, is non-vacuous; otherwise, returns 'false'.
 boolean evidenceIsPropagated()
          Returns 'true' if the evidence potential for this Node, incorporated within the current junction tree potentials, is non-vacuous; otherwise, returns 'false'.
 boolean evidenceToPropagate()
          Returns 'true' if the entered and the propagated evidence differ; otherwise, returns 'false'.
 java.lang.String getAttribute(java.lang.String key)
          Returns the value associated with a particular attribute in the attribute list for this Node.
 java.util.LinkedList getAttributes()
          Returns a LinkedList of attributes associated with this Node.
 NetworkModel.Category getCategory()
          Returns the Category of this Node.
 NodeList getChildren()
          Returns a NodeList with the child Nodes of this Node.
 Domain getDomain()
          Deprecated. Replaced by getHomeDomain().
 NetworkModel.Constraint getEdgeConstraint(Node node)
          Returns the constraint between this and node.
 NetworkModel getHome()
          Returns the Class or Domain containing this Node.
 Class getHomeClass()
          Returns the Class containing this Node.
 Domain getHomeDomain()
          Returns the Domain containing this Node.
 Node getInstance()
          Returns the InstanceNode containing this (cloned) output node.
 JunctionTree getJunctionTree()
          Returns the JunctionTree to which this Node belongs.
 NetworkModel.Kind getKind()
          Returns the Kind of this Node.
 java.lang.String getLabel()
          Returns the label of this Node.
 Node getMaster()
          Returns the "master" of this (cloned) output Node of an InstanceNode (i.e., the Node cloned to get this output Node).
 Model getModel()
          Returns the model of this Node.
 java.lang.String getName()
          Returns the name of this Node.
 NodeList getParents()
          Returns a NodeList with the parent Nodes of this Node.
 java.awt.geom.Point2D getPosition()
          Returns the position of this Node.
 NodeList getSource()
          Returns a NodeList of Class nodes that identifies this Domain node.
 java.lang.Object getUserData()
          Returns the value stored within the user data slot of this node.
 boolean likelihoodIsEntered()
          Returns 'true' if the evidence potential, currently registered with this Node, is a likelihood; otherwise, returns 'false'.
 boolean likelihoodIsPropagated()
          Returns 'true' if the evidence potential for this Node, incorporated within the current junction tree potentials, a likelihood; otherwise, returns 'false'.
 void removeFromInputs()
          Removes this Node from the set of input nodes of its class.
 void removeFromOutputs()
          Removes this Node from the set of output nodes of its Class.
 void removeParent(Node parent)
          Removes the directed link between a parent and this Node.
 void reverseEdge(Node node)
          Reverses the edge between this Node and the specified neighbor.
 void setAttribute(java.lang.String key, java.lang.String value)
          Sets a value for a particular attribute in the attribute list for this Node.
 void setEdgeConstraint(Node node, NetworkModel.Constraint constraint)
          Sets a constraint between this Node and another Node.
 void setLabel(java.lang.String newLabel)
          Sets the label of this Node.
 void setName(java.lang.String newName)
          Sets the name of this Node.
 void setPosition(java.awt.geom.Point2D p)
          Sets the position of this Node.
 void setUserData(java.lang.Object data)
          Sets some user-defined data for this Node.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

addParent

public void addParent(Node newParent)
               throws ExceptionObjectNotAlive,
                      ExceptionArgumentNotAlive,
                      ExceptionHugin
Adds a node as a new parent of this Node. That is, it adds a directed link from the new parent to this Node.

Parameters:
newParent - the new parent Node.

reverseEdge

public void reverseEdge(Node node)
                 throws ExceptionObjectNotAlive,
                        ExceptionArgumentNotAlive,
                        ExceptionHugin
Reverses the edge between this Node and the specified neighbor.

Parameters:
node - the neighbor in question.

removeParent

public void removeParent(Node parent)
                  throws ExceptionObjectNotAlive,
                         ExceptionArgumentNotAlive,
                         ExceptionHugin
Removes the directed link between a parent and this Node. The table (if any) of the Node will be updated such that the updated table will be the portion of the old table that corresponds to the parent being in its first state.

Parameters:
parent - the parent Node that will be removed.

getChildren

public NodeList getChildren()
                     throws ExceptionObjectNotAlive
Returns a NodeList with the child Nodes of this Node.

getCategory

public NetworkModel.Category getCategory()
                                  throws ExceptionObjectNotAlive
Returns the Category of this Node.

Returns:
The NetworkModel.Category value.

getKind

public NetworkModel.Kind getKind()
                          throws ExceptionObjectNotAlive
Returns the Kind of this Node.

Returns:
The NetworkModel.Kind value.

getLabel

public java.lang.String getLabel()
                          throws ExceptionObjectNotAlive,
                                 ExceptionHugin
Returns the label of this Node.

Returns:
A String.

getName

public java.lang.String getName()
                         throws ExceptionObjectNotAlive,
                                ExceptionHugin
Returns 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.

getJunctionTree

public JunctionTree getJunctionTree()
                             throws ExceptionObjectNotAlive
Returns the JunctionTree to which this Node belongs.

Returns:
A JunctionTree.

getParents

public NodeList getParents()
                    throws ExceptionObjectNotAlive
Returns a NodeList with the parent Nodes of this Node. If no parents exist, an empty NodeList is returned.

Returns:
A NodeList.

getPosition

public java.awt.geom.Point2D getPosition()
                                  throws ExceptionObjectNotAlive,
                                         ExceptionHugin
Returns the position of this Node.

Returns:
A Point2D.Double(x,y).

getUserData

public java.lang.Object getUserData()
                             throws ExceptionObjectNotAlive
Returns 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.

Returns:
The user data Object stored within this Node.

evidenceIsEntered

public boolean evidenceIsEntered()
                          throws ExceptionObjectNotAlive,
                                 ExceptionHugin
Returns 'true' if the evidence potential, currently registered with this Node, is non-vacuous; otherwise, returns 'false'.

evidenceIsPropagated

public boolean evidenceIsPropagated()
                             throws ExceptionObjectNotAlive,
                                    ExceptionHugin
Returns 'true' if the evidence potential for this Node, incorporated within the current junction tree potentials, is non-vacuous; otherwise, returns 'false'.

likelihoodIsEntered

public boolean likelihoodIsEntered()
                            throws ExceptionObjectNotAlive,
                                   ExceptionHugin
Returns 'true' if the evidence potential, currently registered with this Node, is a likelihood; otherwise, returns 'false'.

likelihoodIsPropagated

public boolean likelihoodIsPropagated()
                               throws ExceptionObjectNotAlive,
                                      ExceptionHugin
Returns 'true' if the evidence potential for this Node, incorporated within the current junction tree potentials, a likelihood; otherwise, returns 'false'.

evidenceToPropagate

public boolean evidenceToPropagate()
                            throws ExceptionObjectNotAlive,
                                   ExceptionHugin
Returns 'true' if the entered and the propagated evidence differ; otherwise, returns 'false'.

getAttribute

public java.lang.String getAttribute(java.lang.String key)
                              throws ExceptionObjectNotAlive,
                                     ExceptionHugin,
                                     ExceptionUsage
Returns the value associated with a particular attribute in the attribute list for this Node.

Parameters:
key - a String identifying the attribute in question.
Returns:
A String containing the attribute value.

See Also:
setAttribute

setAttribute

public void setAttribute(java.lang.String key,
                         java.lang.String value)
                  throws ExceptionObjectNotAlive,
                         ExceptionHugin
Sets a value for a particular attribute in the attribute list for this Node. If the null value is provided, the attribute is removed.

Parameters:
key - a String identifying the attribute in question.
value - a String containing the attribute value.

See Also:
getAttribute

getAttributes

public java.util.LinkedList getAttributes()
                                   throws ExceptionObjectNotAlive,
                                          ExceptionHugin
Returns a LinkedList of attributes associated with this Node.

delete

public void delete()
            throws ExceptionObjectNotAlive,
                   ExceptionHugin
Deletes this Node.

setLabel

public void setLabel(java.lang.String newLabel)
              throws ExceptionHugin,
                     ExceptionObjectNotAlive
Sets the label of this Node.

Parameters:
newLabel - the label (a String).

setName

public void setName(java.lang.String newName)
             throws ExceptionHugin,
                    ExceptionObjectNotAlive
Sets the name of this Node. The name must be valid, i.e., it must follow the rules that govern the validity of C identifiers, and no other node in the network to which this Node belongs must have the same name.

Parameters:
newName - the name of the Node (a String).

setPosition

public void setPosition(java.awt.geom.Point2D p)
                 throws ExceptionObjectNotAlive,
                        ExceptionHugin
Sets the position of this Node.

Parameters:
p - the desired (x,y) coordinates of the Node (a Point2D).

setUserData

public void setUserData(java.lang.Object data)
                 throws ExceptionObjectNotAlive,
                        ExceptionHugin
Sets some user-defined data for this Node. The Hugin API provides a data slot within each Node. 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 - an Object contaning the user-defined data associated with this Node.

getModel

public Model getModel()
               throws ExceptionObjectNotAlive,
                      ExceptionArgumentNotAlive,
                      ExceptionHugin
Returns the model of this Node.

Returns:
A Model.

getHomeClass

public Class getHomeClass()
                   throws ExceptionObjectNotAlive
Returns the Class containing this Node. Returns null if the Node belongs to a Domain.
Returns:
The Class containing this Node.

getHomeDomain

public Domain getHomeDomain()
                     throws ExceptionObjectNotAlive
Returns the Domain containing this Node. Returns null if the Node belongs to a Class.
Returns:
The Domain containing this Node.

getDomain

public Domain getDomain()
                 throws ExceptionObjectNotAlive
Deprecated. Replaced by getHomeDomain().


getHome

public NetworkModel getHome()
                     throws ExceptionObjectNotAlive
Returns the Class or Domain containing this Node.
Returns:
The NetworkModel containing this Node.

setEdgeConstraint

public void setEdgeConstraint(Node node,
                              NetworkModel.Constraint constraint)
                       throws ExceptionObjectNotAlive,
                              ExceptionHugin
Sets a constraint between this Node and another Node. The constraint must be an instance of NetworkModel.Constraint.

Parameters:
node - the second node in the constraint.
constraint - the NetworkModel.Constraint to be set.

getEdgeConstraint

public NetworkModel.Constraint getEdgeConstraint(Node node)
                                          throws ExceptionObjectNotAlive,
                                                 ExceptionHugin
Returns the constraint between this and node.

Parameters:
node - the second node in the constraint.
Returns:
The NetworkModel.Constraint set between the two nodes.

getMaster

public Node getMaster()
               throws ExceptionObjectNotAlive,
                      ExceptionHugin
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 Node if it is an output clone; otherwise, the method returns null.

getInstance

public Node getInstance()
                 throws ExceptionObjectNotAlive,
                        ExceptionHugin
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.

addToOutputs

public void addToOutputs()
                  throws ExceptionObjectNotAlive,
                         ExceptionHugin
Makes this Node become an output node of its Class. The Node must not already be an output or input Node of its Class.

removeFromOutputs

public void removeFromOutputs()
                       throws ExceptionObjectNotAlive,
                              ExceptionHugin
Removes this Node from the set of output nodes of its Class.

addToInputs

public void addToInputs()
                 throws ExceptionObjectNotAlive,
                        ExceptionHugin
Makes this Node become an input node of its Class. The node must not already be an input or output node of its Class, it must not be an output clone associated with an InstanceNode, and, most importantly, it must not have parents.

removeFromInputs

public void removeFromInputs()
                      throws ExceptionObjectNotAlive,
                             ExceptionHugin
Removes this Node from the set of input nodes of its class.

getSource

public NodeList getSource()
                   throws ExceptionObjectNotAlive,
                          ExceptionHugin
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 an influence diagram 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.