WIP: Adding Transitions to the Conditions Tree: success !

This commit is contained in:
Jean Sirmai 2022-01-07 21:16:30 +01:00
parent 46db1e5ad6
commit e364b97cbf
Signed by: jean
GPG Key ID: FB3115C340E057E3
1 changed files with 16 additions and 13 deletions

View File

@ -45,13 +45,11 @@ class TransTreeNode(NodeMixin):
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
def add_parent_leaf_node(self, parent_node, transition_node_id): def add_parent_leaf_node(self, parent_node, transition_node_id):
print('orphan transition node', transition_node_id, # print('orphan transition is adopted by leaf node', parent_node.id)
'is to be adopted by leaf node', parent_node.id, self.parent = parent_node
type(self),
type(parent_node))
# self.parent = parent_node
for i in conditions_set: # sorted(conditions_set, key=i.id): for i in conditions_set: # sorted(conditions_set, key=i.id):
@ -68,17 +66,22 @@ for i in conditions_list:
else: else:
root = j root = j
for i in transitions_set: for condition_node in LevelOrderIter(root):
transition_node = TransTreeNode(i[1]) if condition_node.is_leaf:
for condition_node in LevelOrderIter(root): for i in transitions_set:
if condition_node.is_leaf: transition_node = TransTreeNode(i[1])
if (str(condition_node.id) == transition_node.parent_node_id): if (str(condition_node.id) == i[1]):
transition_node.add_parent_leaf_node(condition_node, i[1]) transition_node.add_parent_leaf_node(condition_node, transition_node)
for pre, fill, node in RenderTree(root): for pre, fill, node in RenderTree(root):
treestr = u"%s%s" % (pre, node.id) treestr = u"%s%s" % (pre, node.id)
print(treestr.ljust(16), node.weight, ' arrow(s) at [site', node.site, if (type(node) == CondTreeNode):
'in cell', node.x, end=']\n') print(treestr.ljust(16), node.weight, ' arrow(s) at [site', node.site,
'in cell', node.x, end='')
if (not node.depth == 2):
print(end=']\n')
else:
print(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])