COM.hugin.HAPI
Class Node

java.lang.Object
  extended byCOM.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 for 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 setAttributes(java.util.LinkedList attributes)
          Sets the attributes of this Node to 'attributes', which must be a LinkedList of Attribute objects.
 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.
 void switchParent(Node oldParent, Node newParent)
          Replace the given parent node with the new 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 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.
Throws:
ExceptionHugin

reverseEdge

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

Parameters:
node - the neighbor in question.
Throws:
ExceptionHugin

removeParent

public void removeParent(Node parent)
                  throws 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.
Throws:
ExceptionHugin

switchParent

public void switchParent(Node oldParent,
                         Node newParent)
                  throws ExceptionHugin
Replace the given parent node with the new node. The old and new parent must be compatible. That is, they must be of the same class, and have an identical state set.

Parameters:
newParent - The new parent
oldParent - The old parent
Throws:
ExceptionHugin

getChildren

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

Throws:
ExceptionHugin

getCategory

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

Returns:
The NetworkModel.Category value.
Throws:
ExceptionObjectNotAlive

getKind

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

Returns:
The NetworkModel.Kind value.
Throws:
ExceptionObjectNotAlive

getLabel

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

Returns:
A String.
Throws:
ExceptionHugin

getName

public java.lang.String getName()
                         throws 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.
Throws:
ExceptionHugin

getJunctionTree

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

Returns:
A JunctionTree.
Throws:
ExceptionHugin

getParents

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

Returns:
A NodeList.
Throws:
ExceptionHugin

getPosition

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

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

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.
Throws:
ExceptionObjectNotAlive

evidenceIsEntered

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

Throws:
ExceptionHugin

evidenceIsPropagated

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

Throws:
ExceptionHugin

likelihoodIsEntered

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

Throws:
ExceptionHugin

likelihoodIsPropagated

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

Throws:
ExceptionHugin

evidenceToPropagate

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

Throws:
ExceptionHugin

getAttribute

public java.lang.String getAttribute(java.lang.String key)
                              throws ExceptionHugin
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.

Throws:
ExceptionHugin
See Also:
setAttribute

setAttribute

public void setAttribute(java.lang.String key,
                         java.lang.String value)
                  throws 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.

Throws:
ExceptionHugin
See Also:
getAttribute

getAttributes

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

Throws:
ExceptionHugin

setAttributes

public void setAttributes(java.util.LinkedList attributes)
                   throws ExceptionHugin
Sets the attributes of this Node to 'attributes', which must be a LinkedList of Attribute objects.

Throws:
ExceptionHugin

delete

public void delete()
            throws ExceptionHugin
Deletes this Node.

Throws:
ExceptionHugin

setLabel

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

Parameters:
newLabel - the label (a String).
Throws:
ExceptionHugin

setName

public void setName(java.lang.String newName)
             throws ExceptionHugin
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).
Throws:
ExceptionHugin

setPosition

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

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

setUserData

public void setUserData(java.lang.Object data)
                 throws 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.
Throws:
ExceptionHugin

getModel

public Model getModel()
               throws ExceptionHugin
Returns the Model for this Node.

Returns:
A Model object.
Throws:
ExceptionHugin

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.
Throws:
ExceptionObjectNotAlive

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.
Throws:
ExceptionObjectNotAlive

getDomain

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

Throws:
ExceptionObjectNotAlive

getHome

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

Returns:
The NetworkModel containing this Node.
Throws:
ExceptionObjectNotAlive

setEdgeConstraint

public void setEdgeConstraint(Node node,
                              NetworkModel.Constraint constraint)
                       throws 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.
Throws:
ExceptionHugin

getEdgeConstraint

public NetworkModel.Constraint getEdgeConstraint(Node node)
                                          throws 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.
Throws:
ExceptionHugin

getMaster

public Node getMaster()
               throws 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.
Throws:
ExceptionHugin

getInstance

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

addToOutputs

public void addToOutputs()
                  throws 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.

Throws:
ExceptionHugin

removeFromOutputs

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

Throws:
ExceptionHugin

addToInputs

public void addToInputs()
                 throws 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.

Throws:
ExceptionHugin

removeFromInputs

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

Throws:
ExceptionHugin

getSource

public NodeList getSource()
                   throws 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.
Throws:
ExceptionHugin