Boost logo

Boost Users :

From: Magnus Ekdahl (maguno_at_[hidden])
Date: 2006-07-19 04:28:07


Hi,

I put in 0,1,2,3,4 into a Fibonacci heap, manipulate some and get 0,2,4,1,25
back. With the relaxed heap I get 0,2,4,1,3 back, which is as expected with my
code. AFAIK this is due to a bug in the Fibonacci heap?

Anyway here is code adopted from the cvs (fibonacci_heap.cpp) that reproduces
the result on two different machines (intel/amd), where the programs are
compiled using g++ 4.0.4. Any help in clearing out this confusing result is
appreciated :)

#include <iostream>
#include <cstdlib>
#include <vector>
#include <boost/pending/Fibonacci_heap.hpp>
#include <boost/pending/relaxed_heap.hpp>
#include <boost/graph/graph_utility.hpp>
#include <boost/pending/indirect_cmp.hpp>

using namespace std;
using namespace boost;

int main(int argc, char *argv[])
{
   typedef indirect_cmp<unsigned*,std::less<unsigned> > ICmp;
   unsigned current;
   const unsigned N=5;
   vector<unsigned> w(N);

   ICmp cmp(&w[0], std::less<unsigned>());
   Fibonacci_heap<unsigned, ICmp> Q(N, cmp);
   //relaxed_heap<unsigned, ICmp> Q(N, cmp);

   Q.push(0);
   current=Q.top();
   cout << current << " ";
   Q.pop();
   w[1]=180428938;
   Q.push(1);
   w[2]=84693088;
   Q.push(2);
   w[3]=168169277;
   Q.push(3);
   w[4]=171463691;
   Q.push(4);
   current = Q.top();
   cout << current << " ";
   Q.pop();
   w[3]=164976049;
   Q.update(3);
   w[4]=59651664;
   Q.update(4);
   current = Q.top();
   cout << current << " ";
   Q.pop();
   w[1]=71988538;
   Q.update(1);
   w[3]=118964142;
   Q.update(3);
   current = Q.top();
   cout << current << " ";
   Q.pop();
   w[3]=42423833;
   Q.update(3);
   current = Q.top();
   cout << current << " ";
   Q.pop();

   return EXIT_SUCCESS;
}


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net