This is my first time using a priority queue. I'm trying to implement Dijkstra's algorithm for school and I figured I need a min heap to do this. Right now my nodes are pointers and I want to compare their weight, but I don't think I can overload > and < with pointers? Is there a way I could accomplish this?
Code this far:
priority_queue<Node*, vector<Node*>, node_comparison> minHeap;
And then I have a struct to compare the node's weights
struct node_comparison
{
bool operator<( const Node* a, const Node* b ) const
{
return a->totalWeight < b->totalWeight;
}
};
However it says there are too many parameters for this operator function. I've been trying to figure out how I could manage a min heap priority queue with my nodes for a while now and keep getting stuck. Any ideas?
std::less<int>. You need to implement something similar forNode*. - Peter Wood