-
Notifications
You must be signed in to change notification settings - Fork 0
/
tree_structs.py
29 lines (22 loc) · 1014 Bytes
/
tree_structs.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
__author__ = 'Lena Collienne'
import os
from ctypes import *
class NODE(Structure):
_fields_ = [('parent', c_long), ('children', c_long * 2), ('time', c_long)] # The order of arguments here matters! Needs to be the same as in C code!
def __init_(self, parent, children, time):
self.parent = parent
self.children = children
self.time = time
class TREE(Structure):
_fields_ = [('tree', POINTER(NODE)), ('num_leaves', c_long), ('root_time', c_long), ('sos_d', c_long)] # Everything from struct definition in C
def __init_(self, tree, num_leaves, root_time, sos_d):
self.tree = tree
self.num_leaves = num_leaves
self.root_time = root_time
self.sos_d = sos_d
class TREE_LIST(Structure):
_fields_ = [('trees', POINTER(TREE)), ('num_trees', c_long), ('max_root_time', c_long)]
def __init_(self, trees, num_trees, max_root_time):
self.trees = trees
self.num_trees = num_trees
self.max_root_time = max_root_time