-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNode.py
More file actions
132 lines (117 loc) · 3.44 KB
/
Copy pathNode.py
File metadata and controls
132 lines (117 loc) · 3.44 KB
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
class Node:
def __init__(self, name=None, gate=None, id=None, mother=None, prob=None):
"""
Constructor function of class Node
:param name: The name(description) of the node
:param gate: The type of the gate that linked with child nodes
:param id: The id of the node
:param mother: mother node
:param prob: The probability of the node
"""
self.name = name
self.gate = gate
self.id = id
self.child = []
self.mother = mother
self.prob = prob
def set_name(self, name):
"""
Set the name(description) of the node by given parameter
:param name: The name(description) that user want to give
:return: None
"""
self.name = name
def get_name(self):
"""
Return the name(description) of the node
:return: The name(description) of the node
"""
return self.name
def set_gate(self, gate):
"""
Set the gate of the node by given parameter
:param gate: The gate that user want to give
:return: None
"""
self.gate = gate
def get_gate(self):
"""
Return the gate of the node
:return: The gate of the node
"""
return self.gate
def set_mother(self, mother):
"""
Set the mother of the node by given parameter
:param mother: The gate that user want to give
:return: None
"""
self.mother = mother
def get_mother(self):
"""
Return the mother of the node
:return: The mother of the node
"""
return self.mother
def get_id(self):
"""
Return the id of the node
:return: The id of the node
"""
return self.id
def get_numChild(self):
"""
Return the number of child
:return: The number of child
"""
return len(self.child)
def get_children(self):
"""
Return the list of child
:return: The list of child
"""
return self.child
def check_type(self, gate):
"""
Check wheter gate type is the same with the given parameter
:param gate: The parameter that want to check
:return: Boolean value based on parameter
"""
return self.gate == gate
def add_child(self, child):
"""
Add child node to the node
:param child: The child node
:return: None
"""
self.child.append(child)
def remove_child(self, child):
"""
Remove given child node from the node
:param child: Given node that want to remove from the parameter
:return: None
"""
self.child.remove(child)
def find_child(self, child):
"""
Return the boolean value whether it has given child or not
:param child: Given child
:return: The boolean value about the child
"""
for my_child in self.child:
if my_child == child:
return True
return False
def set_prob(self, prob):
"""
Set the probability of the node by given parameter
:param prob: The gate that user want to give
:return: None
"""
self.prob = prob
def get_prob(self):
"""
Return the probability of the node
:return: The probability of the node
"""
return self.prob