diff --git a/models/dimers random walk.xml b/models/dimers random walk.xml
index 52f349f..4ee0e00 100644
--- a/models/dimers random walk.xml
+++ b/models/dimers random walk.xml
@@ -92,17 +92,22 @@
the neighbouring space unhit to East of the dimer is empty
and the dimer identified by conditions (1,2) can be moved to East. -->
-
+
+
+
+
+
+
+ parent="7" probability="1">
@@ -112,7 +117,27 @@
+ parent="8" probability="1">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/__pycache__/rules_tree.cpython-39.pyc b/src/__pycache__/rules_tree.cpython-39.pyc
new file mode 100644
index 0000000..bf2a5fc
Binary files /dev/null and b/src/__pycache__/rules_tree.cpython-39.pyc differ
diff --git a/src/rules_tree.py b/src/rules_tree.py
index 42873d2..f91bca2 100644
--- a/src/rules_tree.py
+++ b/src/rules_tree.py
@@ -1,5 +1,5 @@
# https://anytree.readthedocs.io/en/latest/_modules/anytree/node/nodemixin.html
-from anytree import NodeMixin, RenderTree, LevelOrderIter
+from anytree import NodeMixin, LevelOrderIter # , RenderTree
import model
# TODO Contrôles de cohérence des données
@@ -46,7 +46,7 @@ for i in range(0, len(model.testmodel.get_conditions().get_all())):
condition.get_site(),
condition.get_weight())
conditions_set.add(tmp)
- if (tmp.parent_id == 0):
+ if tmp.parent_id == 0:
root = tmp
for i in range(0, len(model.testmodel.get_transitions().get_all())):
@@ -57,26 +57,33 @@ for i in range(0, len(model.testmodel.get_transitions().get_all())):
for i in conditions_set:
for j in conditions_set:
- if ((i != j) & (i.parent_id == j.id)):
+ if (i != j) & (i.parent_id == j.id):
i.is_adopted_by(j)
for condition_node in LevelOrderIter(root):
if condition_node.is_leaf:
for transition_node in transitions_set:
- if (str(condition_node.id) == transition_node.parent_id):
+ if str(condition_node.id) == transition_node.parent_id:
transition_node.is_adopted_by(condition_node)
+"""
## print tree
for pre, fill, node in RenderTree(root):
treestr = u"%s%s" % (pre, node.id)
- if (type(node) == CondTreeNode):
- print(treestr.ljust(16), node.weight, ' arrow(s) at [site', node.site,
+ if type(node) == CondTreeNode:
+ print(treestr.ljust(19), node.weight, ' arrow(s) at [site', node.site,
'in cell', node.x, end='')
- if (not node.depth == 2): # tree.depth()
+ if not node.depth == 2: # tree.depth()
print(end=']\n')
else:
- print('] > ', node.children[0].id, end='\n')
+ print('] --> ', node.children[0].id, end='\n')
+
+"""
+## get the tree
+
+
+def get_tree():
+ return root
-print('\nNext step: single rule extraction from tree. 😃️')
# print([node.id for node in LevelOrderIter(root) if node.is_leaf])
diff --git a/src/show_tree.py b/src/show_tree.py
new file mode 100644
index 0000000..3a0bc19
--- /dev/null
+++ b/src/show_tree.py
@@ -0,0 +1,34 @@
+# from ete2 import Tree
+from anytree import RenderTree
+import rules_tree
+
+tree = rules_tree.get_tree()
+
+print('type: ', type(tree))
+print(tree.depth, ' < depth')
+print(tree.is_leaf, ' < is_leaf')
+print(tree.is_root, ' < is_root')
+print(tree.height, ' < height')
+print(tree.parent, ' < parent')
+print(tree.ancestors, ' < ancestors')
+print(tree.anchestors, ' < anchestors')
+print(tree.siblings, ' < siblings')
+print(len(tree.leaves), ' < len(tree.leaves)')
+print(len(tree.path), ' < len(tree.path)')
+print('path: ', tree.path)
+print('children: ', tree.children)
+print('descendants[0]: ', tree.descendants[0])
+
+print('\n to fix: (leaves)', end='\n\n')
+for pre, fill, node in RenderTree(tree):
+ treestr = u"%s%s" % (pre, node.id)
+ if type(node) == rules_tree.CondTreeNode:
+ print(treestr.ljust(19), node.weight, ' arrow(s) at [site', node.site,
+ 'in cell', node.x, end='')
+ if not node.depth == 2: # tree.depth()
+ print(end=']\n')
+ else:
+ print('] --> ', node.children[0].id, end='\n')
+
+
+print('\nNext step: single rule extraction from tree. 😃️')