Hi...
I am facing problem while operator overloading in the priority queue... my following code snippet return wrong..
struct node
{
int vertex, dist;
node() {};
node(int v, int d) : vertex(v), dist(d) {};
};
bool operator < (node p, node q)
{
if(p.dist > q.dist)
return true;
else if(p.dist == q.dist)
{
if(p.vertex > q.vertex)
return true;
return false;
}
return false;
}
here .. the node priority is sorted according to distance, but when distance (suppose both are 0 ) is same then node is sorted according to the vertex number. for example it becomes
1 0
3 0
2 0
7 69
6 51
4 48 --> which is wrong
Thanks.