class CBNSNode

This data structure holds the information of a Bayesian Node that has discrete states

Public Fields

static int m_nCounter
This variable is used to check for the memory leaks in the program
static int m_nID
This variable is used as a unique identifier for a node

Public Methods

bool IsCategory ()
Returns true if the states of the node belong to a category
bool IsRoot ()
Returns true if the node is a root, ie
bool IsLeaf ()
Returns true if the node is a leaf, ie
bool IsInstantiated ()
Returns true if the node is instantiated

Public

Constructors and Destructor
CBNSNode ()
Default Constructor
CBNSNode (string sStateType, bool bIsCategory)
Constructor with state type and category
CBNSNode (string sLabel, int n_NoOfStates = 1, string sStateType = "string", bool bIsCategory = true)
Constructor with the node label, number of states, state type and category
virtual ~CBNSNode ()
Destructor
Initialization
void Initialize (string sLabel, int n_NoOfStates = 1, string sStateType = "string", bool bIsCategory = true)
Initializes the Node with the node label, number of states, state type and category
virtual void Copy (CBNSNode& cBNSNode)
Copies the contents of cBNSNode
Out Functions
int GetID ()
Returns the unique ID assigned to the node
int GetNoOfStates ()
Returns the number of states of the node
int GetNoOfParents ()
Returns the number of parents of the node
int GetNoOfChildren ()
Returns the number of children of the node
int GetRank ()
Returns the rank of the node
string GetLabel ()
Returns the label of the node
E_STATETYPE GetStateType ()
Returns the state type, ie
CBNSSet <CBNSStateBase *> GetStates ()
Returns the set of states of the node
CBNSSet <CBNSLink*> GetConnectedLinks ()
Returns the set of connected links of the node
CBNSSet <CBNSNode*> GetChildren ()
Returns the set of children of the node
CBNSSet <CBNSNode*> GetParents ()
Returns the set of parents of the node
CBNSSet <CBNSNode*> GetNeighbours ()
Returns the set of neighbours, ie parents + children
CBNSSet <CBNSNode*> GetAncestors ()
Returns the ancestors of the node
CBNSSet <CBNSNode*> GetDescendants ()
Returns the descendants of the node
CBNSSet <CBNSNode*> GetAnc (CBNSSet<CBNSNode*>& parentSet)
Returns the Ancestors given the parent set
CBNSSet <CBNSNode*> GetDes (CBNSSet<CBNSNode*>& childSet)
Returns the
CBNSProbTable* GetProbTable ()
Returns a pointer to the probability table
CBNSProbVector* GetPiVector ()
Returns the Pi Vector, Not implemented<\em>
CBNSProbVector* GetLambdaVector ()
Returns the Lambada vector, Not implemented<\em>
CBNSProbVector* GetBeliefVector ()
Returns the belief vector, Not implemented<\em>
In Functions
void SetRank (int nRank)
Sets the rank of the node to nRank
void SetID (int nId)
Sets the ID of the node to nId
void SetLabel (string sLabel)
Sets the label of the node to sLabel
void SetNoOfStates (int nStates)
Sets the number of states of the node to nStates and creates them
bool SetInstantiated (bool bInstatiated)
Sets the node as instantiated and returns true if instantiated
bool SetInstantiated (int nState)
Instatiates the nState of the node and returns true if succeeded
bool SetInstantiated (vector& vProbVector)
Instatiates the states of the node to the values given in vProbVector and returns true if succeeded
bool SetContingencyTable (CBNSProbTable* pProbTable)
Sets the conditional probability table of the node to pProbTable and checks for the tables sizes and returns true if succeeded
bool SetContingencyTable (vector<CBNSProbVector*>& vProbVector)
Sets the conditional probability table to vProbVector and returns true if succeeded
bool SetBeliefVector (CBNSProbVector* pProbVector)
Sets the belief vector to pProbVector and returns true if succeeded
bool SetBeliefVector (vector& vProbVector)
Sets the belief vector to vProbVector and returns true if succeeded
bool SetLambdaVector (CBNSProbVector* pProbVector)
Sets the belief vector to pProbVector and returns true if succeeded
bool SetLambdaVector (vector& vProbVector)
Sets the Lambda vector to vProbVector and returns true if succeeded
bool SetPiVector (CBNSProbVector* pProbVector)
Sets the belief vector to pProbVector and returns true if succeeded
bool SetPiVector (vector& vProbVector)
Sets the Pi vector to vProbVector and returns true if succeeded
bool SetLinks (CBNSSet<CBNSLink*>& cLinkSet)
Sets the connected links to cBNSLink and updates the table
Update Functions
bool AddState (int nStates)
Adds nStates to the node and returns true when succeeded
bool AddState (CBNSState& strStateSet)
Returns true when the the states categorized by string are added to the node
bool AddState (CBNSState& dStateSet)
Returns true when the the states categorized by double are added to the node
bool AddState (CBNSState& chStateSet)
Returns true when the the states categorized by char are added to the node
bool DeleteState (CBNSState& strStateSet)
Returns true when the the states categorized by string are deleted from the node
bool DeleteState (CBNSState& dStateSet)
Returns true when the the states categorized by double are deleted from the node
bool DeleteState (CBNSState& chStateSet)
Returns true when the the states categorized by char are deleted from the node
bool DeleteState (string sLabel)
Returns true when the the state having label sLabel is deleted from the node
bool AddLink (CBNSLink* pLink, bool bUpdateNodeTable = true)
Returns true when the the link pLink is added to the node
bool AddLink (CBNSSet<CBNSLink*>& cLinkSet, bool bUpdateNodeTable = true)
Returns true when atleast one of the of links in the cLinkSet is added to the node
void AddChild (CBNSNode* pNode)
Adds a child node to the set of child nodes
void AddParent (CBNSNode* pNode, bool bUpdateNodeTable = true)
Adds a parent node to the set of parent nodes
bool DeleteLink (CBNSLink* pLink, bool bUpdateNodeTable = true)
Returns true when the the link pLink is deleted from the node
void UpdateNode ()
Updates the node by ordering the set of parents and children
void InitializeProbVectors ()
Initializes the Lambda, Pi and Belief Vectors
bool CheckTableSize (vector<CBNSProbVector*>& vProbVector)
Returns true if the size of vProbVector is same as the number of states of the node
CBNSProbVector* ComputeMarginal ()
Returns the initial belief vector for the node
void PrintNode ()
Prints the contents of the node to the console
Overloaded Operators
void operator= ( CBNSNode & cNode)
Assignment operator
bool operator== ( CBNSNode& cNode)
Equal operator
bool operator > ( CBNSNode& cNode)
Greater than operator
bool operator < ( CBNSNode& cNode)
Less than operator
Friend Functions
friend ostream& operator<< (ostream &stream, CBNSNode &cNode)
Stream Insertion operator
friend bool sort_node (CBNSNode* pNode1, CBNSNode* pNode2)
Returns true if the ID of pNode1 is less than the ID of pNode2
friend void PrintNodeSet (CBNSSet<CBNSNode*> nodeSet)
Prints the contents of the nodeSet to the console
friend int GetNodeIndex (CBNSSet<CBNSNode*>& vNodeSet, CBNSNode* pNode)
Returns the node index of pNode in vNodeSet

Private

Private Member Variables
int m_nRank
Rank of the node
int m_nNodeId
ID of the node
int m_nStateCounter
State Counter
int m_nNoOfStates
Number of states
bool m_bInstantiated
This variable is true if the node is instantiated
bool m_bStatesCategory
This variable is true if the states of the node belong to a category
string m_sNodeLabel
Label of the node
E_STATETYPE m_eStateType
State type: double or char or string
CBNSProbTable m_cContingencyTable
Conditional probability table
CBNSProbVector m_cLambdaVector
Lambda vector
CBNSProbVector m_cPiVector
Pi Vector
CBNSProbVector m_cBeliefVector
Belief Vector
CBNSSet <CBNSLink*> m_cBNSLinks
Set of Links associated with the node
CBNSSet <CBNSStateBase *> m_cNodeStates
Set of node states
CBNSSet <CBNSNode*> m_cParentNodes
Set of parents
CBNSSet <CBNSNode*> m_cChildNodes
Set of children

Documentation

This data structure holds the information of a Bayesian Node that has discrete states. Nodes that have continuous states are not dealt in this implementation. Each node contains a set of states, a set of parent and child nodes, a set of connected links and a conditional probability table.
static int m_nCounter
This variable is used to check for the memory leaks in the program

static int m_nID
This variable is used as a unique identifier for a node

Constructors and Destructor

CBNSNode()
Default Constructor

CBNSNode(string sStateType, bool bIsCategory)
Constructor with state type and category
Parameters:
sStateType - is either double, char or string
bIsCategory - is true if the state belong to a category

CBNSNode(string sLabel, int n_NoOfStates = 1, string sStateType = "string", bool bIsCategory = true)
Constructor with the node label, number of states, state type and category
Parameters:
sLabel - the label for the node
n_NoOfStates - number of states. Default value is 1
sStateType - is either string, double or char. Default value is "string"
bIsCategory - is true if the states of the node belong to a category. Default value is true

virtual ~CBNSNode()
Destructor

Initialization

void Initialize(string sLabel, int n_NoOfStates = 1, string sStateType = "string", bool bIsCategory = true)
Initializes the Node with the node label, number of states, state type and category. This function is called by all the constructors for initialization
Parameters:
sLabel - the label for the node
n_NoOfStates - number of states. Default value is 1
sStateType - is either string, double or char. Default value is "string"
bIsCategory - is true if the states of the node belong to a category. Default value is true

virtual void Copy(CBNSNode& cBNSNode)
Copies the contents of cBNSNode
Parameters:
cBNSNode - a reference to CBNSNode object

bool IsCategory()
Returns true if the states of the node belong to a category
Returns:
bool

bool IsRoot()
Returns true if the node is a root, ie., if the node has no parents
Returns:
bool

bool IsLeaf()
Returns true if the node is a leaf, ie., if the node has no children
Returns:
bool

bool IsInstantiated()
Returns true if the node is instantiated
Returns:
bool

Out Functions

int GetID()
Returns the unique ID assigned to the node
Returns:
int

int GetNoOfStates()
Returns the number of states of the node
Returns:
int

int GetNoOfParents()
Returns the number of parents of the node
Returns:
int

int GetNoOfChildren()
Returns the number of children of the node
Returns:
int

int GetRank()
Returns the rank of the node
Returns:
int

string GetLabel()
Returns the label of the node
Returns:
string

E_STATETYPE GetStateType()
Returns the state type, ie., double, char or string

CBNSSet <CBNSStateBase *> GetStates()
Returns the set of states of the node
Returns:
a CBNSSet of pointers to CBNSStateBase

CBNSSet <CBNSLink*> GetConnectedLinks()
Returns the set of connected links of the node
Returns:
a CBNSSet of pointers to CBNSLink objects

CBNSSet <CBNSNode*> GetChildren()
Returns the set of children of the node
Returns:
a CBNSSet of pointers to CBNSNode objects

CBNSSet <CBNSNode*> GetParents()
Returns the set of parents of the node
Returns:
a CBNSSet of pointers to CBNSNode objects

CBNSSet <CBNSNode*> GetNeighbours()
Returns the set of neighbours, ie parents + children
Returns:
a CBNSSet of pointers to CBNSNode objects

CBNSSet <CBNSNode*> GetAncestors()
Returns the ancestors of the node
Returns:
a CBNSSet of pointers to CBNSNode objects

CBNSSet <CBNSNode*> GetDescendants()
Returns the descendants of the node
Returns:
a CBNSSet of pointers to CBNSNode objects

CBNSSet <CBNSNode*> GetAnc(CBNSSet<CBNSNode*>& parentSet)
Returns the Ancestors given the parent set. This function is called recursively to get the ancestors of the node and is not advisable to use otherwise
Returns:
a CBNSSet of pointers to CBNSNode objects
Parameters:
parentSet - a CBNSSet of pointers to parent nodes

CBNSSet <CBNSNode*> GetDes(CBNSSet<CBNSNode*>& childSet)
Returns the
Returns:
a CBNSSet of pointers to CBNSNode objects

CBNSProbTable* GetProbTable()
Returns a pointer to the probability table
Returns:
a pointer to CBNSProbTable object

CBNSProbVector* GetPiVector()
Returns the Pi Vector, Not implemented<\em>
Returns:
a pointer to CBNSProbVector

CBNSProbVector* GetLambdaVector()
Returns the Lambada vector, Not implemented<\em>
Returns:
a pointer to CBNSProbVector

CBNSProbVector* GetBeliefVector()
Returns the belief vector, Not implemented<\em>
Returns:
a pointer to CBNSProbVector

In Functions

void SetRank(int nRank)
Sets the rank of the node to nRank
Parameters:
nRank - rank of the node

void SetID(int nId)
Sets the ID of the node to nId
Parameters:
nId - ID of the node

void SetLabel(string sLabel)
Sets the label of the node to sLabel
Parameters:
sLabel - label of the node

void SetNoOfStates(int nStates)
Sets the number of states of the node to nStates and creates them
Parameters:
nStates - number of states

bool SetInstantiated(bool bInstatiated)
Sets the node as instantiated and returns true if instantiated
Returns:
bool
Parameters:
bInstantiate - is true if the node is instantiated

bool SetInstantiated(int nState)
Instatiates the nState of the node and returns true if succeeded
Parameters:
nState - the number of the state return bool

bool SetInstantiated(vector& vProbVector)
Instatiates the states of the node to the values given in vProbVector and returns true if succeeded. The function will return false if the size of vProbVector is not equal to number of states.
Parameters:
vProbVector - a reference to vector object return bool

bool SetContingencyTable(CBNSProbTable* pProbTable)
Sets the conditional probability table of the node to pProbTable and checks for the tables sizes and returns true if succeeded
Returns:
bool
Parameters:
pProbTable - a pointer to CBNSProbTable

bool SetContingencyTable(vector<CBNSProbVector*>& vProbVector)
Sets the conditional probability table to vProbVector and returns true if succeeded
Returns:
bool
Parameters:
vProbVector - a vector of pointers to CBNSProbVector

bool SetBeliefVector(CBNSProbVector* pProbVector)
Sets the belief vector to pProbVector and returns true if succeeded
Returns:
bool
Parameters:
pProbVector - a pointer to CBNSProbVector

bool SetBeliefVector(vector& vProbVector)
Sets the belief vector to vProbVector and returns true if succeeded
Returns:
bool
Parameters:
vProbVector - a reference to vector

bool SetLambdaVector(CBNSProbVector* pProbVector)
Sets the belief vector to pProbVector and returns true if succeeded
Returns:
bool
Parameters:
pProbVector - a pointer to CBNSProbVector

bool SetLambdaVector(vector& vProbVector)
Sets the Lambda vector to vProbVector and returns true if succeeded
Returns:
bool
Parameters:
vProbVector - a reference to vector

bool SetPiVector(CBNSProbVector* pProbVector)
Sets the belief vector to pProbVector and returns true if succeeded
Returns:
bool
Parameters:
pProbVector - a pointer to CBNSProbVector

bool SetPiVector(vector& vProbVector)
Sets the Pi vector to vProbVector and returns true if succeeded
Returns:
bool
Parameters:
vProbVector - a reference to vector

bool SetLinks(CBNSSet<CBNSLink*>& cLinkSet)
Sets the connected links to cBNSLink and updates the table
Returns:
bool
Parameters:
cLinkSet - a CBNSSet of pointers to CBNSLink objects

Update Functions

bool AddState(int nStates)
Adds nStates to the node and returns true when succeeded
Returns:
bool

bool AddState(CBNSState& strStateSet)
Returns true when the the states categorized by string are added to the node
Returns:
bool
Parameters:
strStateSet - a reference to a set of states categorized by string

bool AddState(CBNSState& dStateSet)
Returns true when the the states categorized by double are added to the node
Returns:
bool
Parameters:
dStateSet - a reference to a set of states categorized by double

bool AddState(CBNSState& chStateSet)
Returns true when the the states categorized by char are added to the node
Returns:
bool
Parameters:
chStateSet - a reference to a set of states categorized by char

bool DeleteState(CBNSState& strStateSet)
Returns true when the the states categorized by string are deleted from the node
Returns:
bool
Parameters:
strStateSet - a reference to a set of states categorized by string

bool DeleteState(CBNSState& dStateSet)
Returns true when the the states categorized by double are deleted from the node
Returns:
bool
Parameters:
dStateSet - a reference to a set of states categorized by double

bool DeleteState(CBNSState& chStateSet)
Returns true when the the states categorized by char are deleted from the node
Returns:
bool
Parameters:
chStateSet - a reference to a set of states categorized by char

bool DeleteState(string sLabel)
Returns true when the the state having label sLabel is deleted from the node
Returns:
bool
Parameters:
sLabel - state label

bool AddLink(CBNSLink* pLink, bool bUpdateNodeTable = true)
Returns true when the the link pLink is added to the node. The probability table of the nodes is updated if bUpdateNodeTable is true.
Returns:
bool
Parameters:
pLink - a pointer to CBNSLink object
bUpdateNodeTable - is true if the node table needs updation

bool AddLink(CBNSSet<CBNSLink*>& cLinkSet, bool bUpdateNodeTable = true)
Returns true when atleast one of the of links in the cLinkSet is added to the node. The probability table of the nodes is updated if bUpdateNodeTable is true.
Returns:
bool
Parameters:
cLinkSet - a CBNSSet of pointers to CBNSLink objects
bUpdateNodeTable - is true if the node table needs updation

void AddChild(CBNSNode* pNode)
Adds a child node to the set of child nodes
Parameters:
pNode - a pointer to CBNSNode object

void AddParent(CBNSNode* pNode, bool bUpdateNodeTable = true)
Adds a parent node to the set of parent nodes
Parameters:
pNode - a pointer to CBNSNode object
bUpdateNodeTable - is true if the node table needs updation

bool DeleteLink(CBNSLink* pLink, bool bUpdateNodeTable = true)
Returns true when the the link pLink is deleted from the node. The probability table of the nodes is updated if bUpdateNodeTable is true.
Returns:
bool
Parameters:
pLink - a pointer to CBNSLink object
bUpdateNodeTable - is true if the node table needs updation

void UpdateNode()
Updates the node by ordering the set of parents and children

void InitializeProbVectors()
Initializes the Lambda, Pi and Belief Vectors

bool CheckTableSize(vector<CBNSProbVector*>& vProbVector)
Returns true if the size of vProbVector is same as the number of states of the node
Parameters:
vProbVector - a reference to a vector of pointers to CBNSProbVector objects

CBNSProbVector* ComputeMarginal()
Returns the initial belief vector for the node
Returns:
a pointer to CBNSProbVector

void PrintNode()
Prints the contents of the node to the console

Overloaded Operators

void operator=( CBNSNode & cNode)
Assignment operator
Parameters:
cNode - a reference to CBNSNode

bool operator==( CBNSNode& cNode)
Equal operator
Parameters:
cNode - a reference to CBNSNode

bool operator >( CBNSNode& cNode)
Greater than operator
Parameters:
cNode - a reference to CBNSNode

bool operator <( CBNSNode& cNode)
Less than operator
Parameters:
cNode - a reference to CBNSNode

Friend Functions

friend ostream& operator<<(ostream &stream, CBNSNode &cNode)
Stream Insertion operator
Returns:
ostream
Parameters:
stream - a reference to ostream object
cNode - a reference to CBNSNode object

friend bool sort_node(CBNSNode* pNode1, CBNSNode* pNode2)
Returns true if the ID of pNode1 is less than the ID of pNode2
Returns:
bool
Parameters:
pNode1 - a pointer to CBNSNode
pNode2 - a pointer to CBNSNode

friend void PrintNodeSet(CBNSSet<CBNSNode*> nodeSet)
Prints the contents of the nodeSet to the console
Parameters:
nodeSet - a CBNSSet of pointers to the nodes

friend int GetNodeIndex(CBNSSet<CBNSNode*>& vNodeSet, CBNSNode* pNode)
Returns the node index of pNode in vNodeSet
Returns:
returns -1 if the node doesnt exist in vNodeSet
Parameters:
vNodeSet - a reference to CBNSSet of pointers to nodes
pNode - a pointer to CBNSNode whose index in the set is returned

Private Member Variables

int m_nRank
Rank of the node

int m_nNodeId
ID of the node

int m_nStateCounter
State Counter

int m_nNoOfStates
Number of states

bool m_bInstantiated
This variable is true if the node is instantiated

bool m_bStatesCategory
This variable is true if the states of the node belong to a category

string m_sNodeLabel
Label of the node

E_STATETYPE m_eStateType
State type: double or char or string

CBNSProbTable m_cContingencyTable
Conditional probability table

CBNSProbVector m_cLambdaVector
Lambda vector

CBNSProbVector m_cPiVector
Pi Vector

CBNSProbVector m_cBeliefVector
Belief Vector

CBNSSet <CBNSLink*> m_cBNSLinks
Set of Links associated with the node

CBNSSet <CBNSStateBase *> m_cNodeStates
Set of node states

CBNSSet <CBNSNode*> m_cParentNodes
Set of parents

CBNSSet <CBNSNode*> m_cChildNodes
Set of children


This class has no child classes.

alphabetic index hierarchy of classes


this page has been generated automatically by doc++

(c)opyright by Malte Zöckler, Roland Wunderling
contact: doc++@zib.de