STL priority_queue priority queue small note

Do questions today found a very interesting place, actually was the first time found, alas, still too dishes.

Graph theory to do with the STL in the priority_queue to optimize prim, due to special needs, I need to record spanning tree is which side used.

Thus, type I priority queue data structure defined as follows:

. 1  struct Node // priority queue memory structure, v storage node numbers, e side number storage, dis [] is the shortest distance from the point 
2  {
 . 3      int V, e;
 . 4      Node () {}
 . 5      Node ( int _V, int _E): V (_V), E (_E) {}
 . 6      BOOL  operator <( const Node A) const { return DIS [AV] < DIS [V];}
 . 7 };

 

According to this definition of the final weights obtained and the minimum spanning tree is correct, but choose the wrong side of the sequence occurs.

Guess you like

Origin www.cnblogs.com/mcflurry/p/2964297.html