void NI::contract(uint32_t n1, uint32_t n2, heap_type &heap) { contractedNodes.push_back(n2); #ifdef _DEBUG cout << "degree between " << n2 << " and " << n1 << " is " << degree(n1,n2) << endl; #endif /*_DEBUG*/ for(uint32_t i = 0; i < n; i++) { bool flag = false; for(uint32_t j = 0; j < contractedNodes.size(); j++) { if(contractedNodes[j] == i) { flag = true; break; } } if(flag) continue; #ifdef _DEBUG cout << "degree between " << n2 << " and " << i << " is " << degree(n2,i) << endl; #endif /*_DEBUG*/ values[nodes[i]] += degree(n2, i, true, n1); heap.update(i); } values[nodes[n2]] = 0; heap.remove(n2); }
/** * Add an element to the heap conditionally: * (1) Add the element if we are not on full capacity. * (2) If we are on full capacity, add the element only after comparison. */ bool add (const value_type& value) { if (size<K) { heap.push(value); ++size; return true; } else if (false==compare(heap.top(),value)) { heap.pop (); heap.push (value); return true; } else { return false; } }
static void similar_row_one( const bit_vector& x, const pair<string, bit_vector>& y, heap_type& heap) { uint64_t match_num = x.calc_hamming_similarity(y.second); heap.push(make_pair(match_num, y.first)); }
bool empty () const { return heap.empty(); }
void pop () { if (0<size) { heap.pop(); --size; } }
const value_type& top () const { return heap.top(); }