File tree Expand file tree Collapse file tree 1 file changed +63
-0
lines changed Expand file tree Collapse file tree 1 file changed +63
-0
lines changed Original file line number Diff line number Diff line change
1
+ package DataMining_TAN ;
2
+
3
+ import java .util .ArrayList ;
4
+
5
+ /**
6
+ * 贝叶斯网络节点类
7
+ *
8
+ * @author lyq
9
+ *
10
+ */
11
+ public class Node {
12
+ //节点唯一id,方便后面节点连接方向的确定
13
+ int id ;
14
+ // 节点的属性名称
15
+ String name ;
16
+ // 该节点所连续的节点
17
+ ArrayList <Node > connectedNodes ;
18
+
19
+ public Node (int id , String name ) {
20
+ this .id = id ;
21
+ this .name = name ;
22
+
23
+ // 初始化变量
24
+ this .connectedNodes = new ArrayList <>();
25
+ }
26
+
27
+ /**
28
+ * 将自身节点连接到目标给定的节点
29
+ *
30
+ * @param node
31
+ * 下游节点
32
+ */
33
+ public void connectNode (Node node ) {
34
+ //避免连接自身
35
+ if (this .id == node .id ){
36
+ return ;
37
+ }
38
+
39
+ // 将节点加入自身节点的节点列表中
40
+ this .connectedNodes .add (node );
41
+ // 将自身节点加入到目标节点的列表中
42
+ node .connectedNodes .add (this );
43
+ }
44
+
45
+ /**
46
+ * 判断与目标节点是否相同,主要比较名称是否相同即可
47
+ *
48
+ * @param node
49
+ * 目标结点
50
+ * @return
51
+ */
52
+ public boolean isEqual (Node node ) {
53
+ boolean isEqual ;
54
+
55
+ isEqual = false ;
56
+ // 节点名称相同则视为相等
57
+ if (this .id == node .id ) {
58
+ isEqual = true ;
59
+ }
60
+
61
+ return isEqual ;
62
+ }
63
+ }
You can’t perform that action at this time.
0 commit comments