-
Notifications
You must be signed in to change notification settings - Fork 1
/
node.h
90 lines (64 loc) · 1.46 KB
/
node.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
/*
* node.h
*
* Created on: 2014年11月21日
* Author: xiaoxuliu
*/
#ifndef EXACT_PE_NODE_H_
#define EXACT_PE_NODE_H_
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include "cpt.h"
#include "bn.h"
using namespace std;
class CPT;
class Node
{
public:
/* constructor */
Node(string);
/* define the node as evidence node */
bool setEvidence(bool);
/* if the node is an evidence node */
bool isEvidence();
/* the observed value, only available on evidence node */
bool setValue(string);
/* set the node name */
bool setName(string);
/* return the node name */
string getName();
/* the observed value, only available on evidence node */
string getValue();
/* the corresponding cpt */
CPT* getCPT();
/* set the corresponding cpt */
bool setCPT(CPT);
/* add a node to parent list */
bool addParent(Node*);
/* remove a node from parent list */
bool removeParent(Node*);
/* parent list */
map<string, Node*> getParents();
/* add a node to child list */
bool addChild(Node*);
/* remove a node to child list */
bool removeChild(Node*);
/* child list */
map<string, Node*> getChildren();
private:
/* parent name, parent pointer */
map<string, Node*> _parents;
/* child name, child pointer */
map<string, Node*> _children;
/* if the node is an evidence node */
bool _is_evidence = false;
/* node value */
string _value;
/* node name */
string _name;
/**/
CPT *_cpt;
};
#endif /* EXACT_PE_NODE_H_ */