def clean(self, row, job): if not job._rem: if row in self._telo_rows: mc1p.undo_check_LCA_path(row._set, self._tree) self._telo_rows.remove(row) self._telo_rows_all.remove(job._row) for i in self._telo_contained_in[job._row]: if i in self._telo_rows_all: r = self._matrix.get_row_info(i) minimal = True # check minimality for r in self,_telo_rows: if r < row._set: minimal = False break #endif #endfor if minimal: mc1p.check_LCA_path(r, tre) self._telo_rows.append(r) #endif #endif #endfor else: self._telo_rows_all.remove(job._row)
def test(self, row, job): if not job._rem: minimal = True telo_disc = [] # check minimality for r in self._telo_rows: if r < row._set: minimal = False break #endif #endfor if minimal: i = 0 # remove non minimal rows while i < len(self._telo_rows): if row._set < self._telo_rows[i]: mc1p.undo_check_LCA_path(self._telo_rows[i], self._tree) telo_disc.append(self._telo_rows[i]) del self._telo_rows[i] else: i = i + 1 #endif #endwhile if mc1p.check_LCA_path(row._set, self._tree): self._telo_rows.append(row._set) self._telo_rows_all.append(job._row) return True else: mc1p.undo_check_LCA_path(row._set, self._tree) for r in telo_disc: mc1p.check_LCA_path(r, self._tree) self._telo_rows.append(r) #endfor #endif return False else: self._telo_rows_all.append(job._row) return True #endif #endif return True
def clean(self, row, job): if row._isT: if job._rem and self._r == job._row: self._tree = None self._r = 0 elif not job._rem: if row in self._telo_rows: mc1p.undo_check_LCA_path(row._set, self._tree) self._telo_rows.remove(row) self._telo_rows_all.remove(job._row) for i in self._telo_contained_in[job._row]: if i in self._telo_rows_all: r = self._matrix.get_row_info(i) minimal = True # check minimality for r in self,_telo_rows: if r < row._set: minimal = False break #endif #endfor if minimal: mc1p.check_LCA_path(r, tre) self._telo_rows.append(r) #endif #endif #endfor else: self._telo_rows_all.remove(job._row) #endif #endif # else: # self._part_list[job._row + 1] = [] elif not job._rem: for m in self._mem_list[job._row][1]: self._part_list.remove(m); #endfor for m in self._mem_list[job._row][0]: sort.insert(self._part_list, m, 0, len(self._part_list), c1p.comp_part);
#endif #endfor if not c1p.check_C1P(m): # check matrix is C1P exit(-2) #endif # make PQ-tree tre = pqtree.make_PQR_tree(m) mc1p.fix_tree_node(tre._head) # Step 3 for r in multM._rows: # Steps a and b and c if not mc1p.check_LCA_path(r._set, tre): exit(-1) #endif #endfor: # Step 4 if tre._head._value._type == 'Q': exit(tre._head._value._used) # Step 5 else: # Step 5a K1, K2 = mc1p.count_used(tre) # K1, K2 # Step 5b K = K1 // 2 + K1 % 2 + K2 # K
def test(self, row, job): if row._isT: if self._tree == None: # mat = bm.BinaryMatrix() # for l in self._part_list[job._row]: # for l in self._part_list: # for r in l._list: # mat.add_row_info(r) # #endif # #endfor # if mat._height > 0: # self._tree = c1p.make_PQR_tree(mat) # add leaves # og = [Support(set([x])) for x in self._support] # nodes = [tree.TreeNode(x) for x in self._support] nodes = [] # add internal vertices for p in self._part_list: pcopy = p._part.copy() val = mc1p.PQRTreeValue() node = tree.TreeNode(val) val._support = pcopy._support # og.append(Support(pcopy._support)) if pcopy._part == pcopy._end: val._type = 'P' else: val._type = 'Q' node._child = pcopy._part #endif nodes.append(node) #endfor nodes = sort.sort(nodes, tree.comp_nodes) # delete overlap graphs with the same support i = 0 # component iterator while i < len(nodes) - 1: if nodes[i]._value._support == nodes[i + 1]._value._support: if nodes[i]._value._type == 'P': del nodes[i] elif nodes[i + 1]._value._type == 'P': del nodes[i + 1] else: i += 1 #endif else: i += 1 #endif #endwhile # add root val = mc1p.PQRTreeValue() val._type = 'P' val._support = self._support nodes.append(tree.TreeNode(val)) self._tree = tree.PQRTree() # self._tree._head = c1p.make_PQR_tree_from_partitions(self._support, nodes, og) self._tree._head = mc1p.make_PQR_tree_from_parts(nodes) # mc1p.fix_tree_node(self._tree._head) # else: # self._tree = 0 #endif self._r = job._row #endif if not job._rem and self._tree != 0: # if not any(row._set in l._list for l in self._part_list[self._r]): # if not any(row._set == r._set for r in x._list for x in self._part_list): if not self._used[job._row]: return False #endif minimal = True telo_disc = [] # check minimality for r in self._telo_rows: if r < row._set: minimal = False break #endif #endfor if minimal: i = 0 # remove non minimal rows while i < len(self._telo_rows): if row._set < self._telo_rows[i]: mc1p.undo_check_LCA_path(self._telo_rows[i], self._tree) telo_disc.append(self._telo_rows[i]) del self._telo_rows[i] else: i = i + 1 #endif #endwhile if mc1p.check_LCA_path(row._set, self._tree): self._telo_rows.append(row._set) self._telo_rows_all.append(job._row) return True else: mc1p.undo_check_LCA_path(row._set, self._tree) for r in telo_disc: mc1p.check_LCA_path(r, self._tree) self._telo_rows.append(r) #endfor #endif return False else: self._telo_rows_all.append(job._row) return True #endif # if mc1p.check_LCA_path(row._set, self._tree): # return True # #endif # # mc1p.undo_check_LCA_path(row._set, self._tree) # # return False #endif # else: elif not job._rem: # self._part_list[job._row + 1] = [c1p.PartitionTree(x._part.copy(), copy.copy(x._list)) for x in self._part_list[job._row]] # if not job._rem: # return c1p.test_row(row._set, self._part_list[job._row + 1]) # #endif ret, self._mem_list[job._row] = c1p.test_row(row, self._part_list) self._used[self._t_copy[job._row]] = ret return ret else: self._used[self._t_copy[job._row]] = False #endif return True