-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathr-8.17.py
37 lines (26 loc) · 809 Bytes
/
r-8.17.py
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
def euler_tour(el, d, path):
results = [None, None]
hook_previsit(el, d, path)
left_c = el[0] if len(el) > 0 else None
if left_c is not None:
path.append(0)
results[0] = euler_tour(left_c, d+1, path)
path.pop()
hook_invisit(el, d, path)
right_c = el[1] if len(el) > 1 else None
if right_c is not None:
path.append(1)
results[1] = euler_tour(right_c, d+1, path)
path.pop()
answer = hook_postvisit(el, d, path, results)
return answer
def hook_previsit(el, d, path):
pass
def hook_invisit(el, d, path):
pass
def hook_postvisit(el, d, path, results):
pass
if __name__ == "__main__":
from lxml import etree as et
tree = et.parse('./input/trees/bin_tree_1.xml')
euler_tour(tree.getroot(), 0, [])