Adding Transitions to the Conditions Tree: success !

This commit is contained in:
Jean Sirmai 2022-01-07 21:45:15 +01:00
parent e364b97cbf
commit 93f4a5e2e2
Signed by: jean
GPG Key ID: FB3115C340E057E3
1 changed files with 6 additions and 6 deletions

View File

@ -41,13 +41,13 @@ class CondTreeNode(NodeMixin):
class TransTreeNode(NodeMixin): class TransTreeNode(NodeMixin):
def __init__(self, parent_node_id): def __init__(self, parent_node_id, id):
super(TransTreeNode, self).__init__() super(TransTreeNode, self).__init__()
self.parent_node_id = parent_node_id self.parent_node_id = parent_node_id
self.parent = None self.parent = None
self.id = None self.id = id
def add_parent_leaf_node(self, parent_node, transition_node_id): def add_parent_leaf_node(self, parent_node):
# print('orphan transition is adopted by leaf node', parent_node.id) # print('orphan transition is adopted by leaf node', parent_node.id)
self.parent = parent_node self.parent = parent_node
@ -69,9 +69,9 @@ for i in conditions_list:
for condition_node in LevelOrderIter(root): for condition_node in LevelOrderIter(root):
if condition_node.is_leaf: if condition_node.is_leaf:
for i in transitions_set: for i in transitions_set:
transition_node = TransTreeNode(i[1]) transition_node = TransTreeNode(i[1], i[0])
if (str(condition_node.id) == i[1]): if (str(condition_node.id) == i[1]):
transition_node.add_parent_leaf_node(condition_node, transition_node) transition_node.add_parent_leaf_node(condition_node)
for pre, fill, node in RenderTree(root): for pre, fill, node in RenderTree(root):
@ -82,6 +82,6 @@ for pre, fill, node in RenderTree(root):
if (not node.depth == 2): if (not node.depth == 2):
print(end=']\n') print(end=']\n')
else: else:
print(end='] *** \n') print('] > ', node.children[0].id, end='\n')
# print([node.id for node in LevelOrderIter(root) if node.is_leaf]) # print([node.id for node in LevelOrderIter(root) if node.is_leaf])