def mergeMinset(self, minset_map, minset, minset_num): if len(self.child_list) == 0: #root_mrq = self.findRoot() #root_mrq.__printAll__() return self if len(self.child_list) == 1: child = self.child_list[0] tmp = child.mergeMinset(minset_map, minset, minset_num) if tmp is not None and tmp.is_free_vertex is False and minset_map[self] == minset_map[tmp]: new_op = None st_type = Rule.get_st(tmp, self) print "1st_type:", st_type op1_child, op2_child = [], [] new_op = Op.merge(tmp, self, st_type, op1_child, op2_child) minset_map[new_op] = minset_map[self] minset.append(new_op) self = new_op return self if len(self.child_list) == 2: [lchild, rchild] = self.child_list lop = lchild.mergeMinset(minset_map, minset, minset_num) rop = rchild.mergeMinset(minset_map, minset, minset_num) if lop is not None and lop.is_free_vertex is False and minset_map[self] == minset_map[lop]: new_op = None st_type = Rule.get_st(lop, self) print "2lst_type:", st_type op1_child, op2_child = [], [] new_op = Op.merge(lop, self, st_type, op1_child, op2_child) minset_map[new_op] = minset_map[self] minset.append(new_op) self = new_op if rop is not None and rop.is_free_vertex is False and minset_map[self] == minset_map[rop]: new_op = None st_type = Rule.get_st(rop, self) print "2rst_type:", st_type op1_child, op2_child = [], [] new_op = Op.merge(rop, self, st_type, op1_child, op2_child) minset_map[new_op] = minset_map[self] minset.append(new_op) self = new_op return self '''for child in self.child_list: