WIP: Adding Transitions to the Conditions Tree: success !
This commit is contained in:
parent
46db1e5ad6
commit
e364b97cbf
|
@ -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])
|
||||||
|
|
Loading…
Reference in New Issue