edu.ksu.cis.bnj.bbn
Class BBNNode

java.lang.Object
  extended bysalvo.jesus.graph.VertexImpl
      extended byedu.ksu.cis.kdd.util.graph.Node
          extended byedu.ksu.cis.bnj.bbn.BBNNode
All Implemented Interfaces:
java.lang.Cloneable, salvo.jesus.graph.GraphComponent, HasProperty, salvo.jesus.graph.LabeledGraphComponent, java.io.Serializable, salvo.jesus.graph.Vertex
Direct Known Subclasses:
Clique, PRMNode

public class BBNNode
extends Node
implements java.lang.Cloneable

A wrapper for BBNNode. Contains query-related functions.

The constants (NORMAL, UTILITY, DECISION) here define the node types. Note that we still allow evidence values to be loaded in the node in any type.

Author:
Roby Joehanes
See Also:
Serialized Form

Field Summary
protected  BBNCPF cpf
          We store the PDF in a hashtable.
static int DECISION
          Denotes whether this node is a decision node
protected  java.lang.Object evidenceValue
          This is the node's evidence value.
static int NORMAL
          Denotes whether this node is a normal node
protected  int type
          Sets the node type.
static int UTILITY
          Denotes whether this node is a utility node
protected  BBNValue values
          Set of possible values of the node (or a function that denotes the range of values, if it is continuous case).
 
Fields inherited from class edu.ksu.cis.kdd.util.graph.Node
name, owner, property
 
Fields inherited from class salvo.jesus.graph.VertexImpl
object
 
Constructor Summary
BBNNode()
           
BBNNode(Graph owner, java.lang.String name)
           
 
Method Summary
 java.lang.Object clone()
          Clone the node.
 boolean equals(java.lang.Object o)
          Equals
 BBNCPF getCPF()
          Returns the CPF.
 double getCPFValue(java.util.Hashtable values)
          Queries to the CPT (or CPF, in case of continuous value).
 java.lang.Object getEvidenceValue()
          Returns the evidence value. null means this node is not an evidence node
 java.util.Hashtable getParentsEvidenceSet()
           
 int getType()
          Returns the type.
 BBNValue getValues()
          Returns the value(s).
 boolean isDecision()
          To enquire whether this node is a decision node
 boolean isEvidence()
          Check whether this node is an evidence node or not
 boolean isQuery()
          Check whether this node is a query node or not.
 boolean isUtility()
          To enquire whether this node is a utility node
 void putCPFValue(java.util.Hashtable q, BBNPDF v)
          Populating the conditional probability function (CPF)
 double query(java.util.Hashtable v)
          An alias to getCPFValue
 java.util.List queryColumn(java.util.Hashtable values)
           
 void reconstructCPF()
           
 void removeCPFValue(java.util.Hashtable q)
          Removing a specific entry from CPF.
 void resetCache()
          Reset the cache
 void resetCPF()
          Resets the CPF to null
 void setCPF(BBNCPF cpf)
          Sets the CPF.
 void setCPF(java.util.Hashtable cpf)
          Sets the CPF.
 void setEvidenceValue(java.lang.Object evidenceValue)
          Sets the evidence value.
 void setType(int type)
          Sets the type.
 void setValues(BBNValue value)
          Sets the value(s).
 java.lang.String toVerboseString()
          To dump more elaborate info.
 void unsetEvidenceValue()
          Unsets the evidence value.
 
Methods inherited from class edu.ksu.cis.kdd.util.graph.Node
getAncestors, getChildren, getChildrenNames, getDescendants, getLabel, getName, getOwner, getParentNames, getParents, getProperty, getProperty, hashCode, putProperty, removeProperty, setName, setOwner, setProperty, toString
 
Methods inherited from class salvo.jesus.graph.VertexImpl
getObject, hasLabel, setLabel, setObject
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

NORMAL

public static final int NORMAL
Denotes whether this node is a normal node

See Also:
Constant Field Values

UTILITY

public static final int UTILITY
Denotes whether this node is a utility node

See Also:
Constant Field Values

DECISION

public static final int DECISION
Denotes whether this node is a decision node

See Also:
Constant Field Values

evidenceValue

protected java.lang.Object evidenceValue
This is the node's evidence value. If null, then the node is not an evidence node.


values

protected BBNValue values
Set of possible values of the node (or a function that denotes the range of values, if it is continuous case). For example: { yes, no }


type

protected int type
Sets the node type. Defaults to normal.


cpf

protected BBNCPF cpf
We store the PDF in a hashtable.

Constructor Detail

BBNNode

public BBNNode(Graph owner,
               java.lang.String name)

BBNNode

public BBNNode()
Method Detail

equals

public boolean equals(java.lang.Object o)
Equals

Overrides:
equals in class Node
See Also:
Object.equals(Object)

getEvidenceValue

public java.lang.Object getEvidenceValue()
Returns the evidence value. null means this node is not an evidence node

Returns:
Object

setEvidenceValue

public void setEvidenceValue(java.lang.Object evidenceValue)
Sets the evidence value.

Parameters:
evidenceValue - The evidence value to set

unsetEvidenceValue

public void unsetEvidenceValue()
Unsets the evidence value.


isEvidence

public boolean isEvidence()
Check whether this node is an evidence node or not

Returns:
boolean

getParentsEvidenceSet

public java.util.Hashtable getParentsEvidenceSet()

isQuery

public boolean isQuery()
Check whether this node is a query node or not. Basically a negation of isEvidence.

Returns:
boolean

reconstructCPF

public void reconstructCPF()

getValues

public BBNValue getValues()
Returns the value(s).

Returns:
BBNValue

setValues

public void setValues(BBNValue value)
Sets the value(s).

Parameters:
value - The value to set

resetCache

public void resetCache()
Reset the cache


getCPFValue

public double getCPFValue(java.util.Hashtable values)
Queries to the CPT (or CPF, in case of continuous value).

Parameters:
values - The query values in a hash table
Returns:
double the return value.

query

public double query(java.util.Hashtable v)
An alias to getCPFValue

Parameters:
v -
Returns:
double
See Also:
getCPFValue(Hashtable)

putCPFValue

public void putCPFValue(java.util.Hashtable q,
                        BBNPDF v)
Populating the conditional probability function (CPF)

Parameters:
q - The query
v - The actual value

removeCPFValue

public void removeCPFValue(java.util.Hashtable q)
Removing a specific entry from CPF.

Parameters:
q - the query

queryColumn

public java.util.List queryColumn(java.util.Hashtable values)

getType

public int getType()
Returns the type.

Returns:
int

setType

public void setType(int type)
Sets the type.

Parameters:
type - The type to set

isDecision

public boolean isDecision()
To enquire whether this node is a decision node

Returns:
boolean

isUtility

public boolean isUtility()
To enquire whether this node is a utility node

Returns:
boolean

getCPF

public BBNCPF getCPF()
Returns the CPF.

Returns:
Hashtable

setCPF

public void setCPF(java.util.Hashtable cpf)
Sets the CPF.

Parameters:
cpf - The cpf to set

setCPF

public void setCPF(BBNCPF cpf)
Sets the CPF.

Parameters:
cpf - The cpf to set

resetCPF

public void resetCPF()
Resets the CPF to null


toVerboseString

public java.lang.String toVerboseString()
To dump more elaborate info. For debugging

Returns:
String the info

clone

public java.lang.Object clone()
Clone the node. Cache is not cloned. The owner graph is empty (you have to set this manually).

See Also:
Object.clone()