Ejemplo n.º 1
0
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);
}
Ejemplo n.º 2
0
  /**
   * 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;
   }
 }
Ejemplo n.º 3
0
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));
}
Ejemplo n.º 4
0
 bool empty () const { return heap.empty(); }
Ejemplo n.º 5
0
 void pop () { if (0<size) { heap.pop(); --size; } }
Ejemplo n.º 6
0
 const value_type& top () const { return heap.top(); }