I need to use Fibonacci heap in my project and I am trying to use it from boost library. But I cannot figure out how to set up a user defined compare function for arbitrary data type. I need to construct a min heap for struct node defined as follows:
struct node
{
int id;
int weight;
struct node* next;
/* dist is a global array of integers */
bool operator > (struct node b) //Boost generates a Max-heap. What I need is a min-heap.
{return dist[id] < dist[b.id] ? 1:0 ;} //That's why "<" is used for "operator >".
bool operator < (struct node b)
{return dist[id] > dist[b.id] ? 1:0 ;}
bool operator >=(struct node b)
{return dist[id] <= dist[b.id] ? 1:0 ;}
bool operator <=(struct node b)
{return dist[id] >= dist[b.id] ? 1:0 ;}
node()
{
id=0;
weight=0;
next=NULL;
}
};
I looked up the documentation and there was a compare class. But it did not contain any element. Please tell me how to set up a user defined compare function. Thank you in advance.