Main Page   Class Hierarchy   Compound List   File List   Compound Members  

pQueue.h

00001 /****************************************************
00002  *  Bachelor Project:                               *
00003  *  External Memory Minimum Spanning Trees          *
00004  *  by Dominik Schultes <mail@dominik-schultes.de>  *
00005  *                                                  *
00006  *                pQueue.h                          *
00007  *                                                  *
00008  *  July 22, 2003                                   *
00009  ****************************************************/
00010 
00011 #ifndef PQUEUE_H
00012 #define PQUEUE_H
00013 
00014 
00015 #include "../stxxl/containers/priority_queue.h"
00016 
00017 #include "../data_structures/edgeVector.h"
00018 #include "../data_structures/mst.h"
00019 
00020 
00027 class PQueue
00028 {
00029  private:
00031     typedef stxxl::PRIORITY_QUEUE_GENERATOR<RelabeledEdge,
00032                                             SourceWeightOrdering<RelabeledEdge>,
00033                                             DS_PQUEUE_INTERNAL_MEMORY,
00034                                             DS_PQUEUE_MAX_SIZE>::result PriorityQueue;
00035     
00036  public:
00044     PQueue(EdgeVector<Edge> &graph, MST &result, NodeCount noOfNodesInIntMem)
00045         : _graph( graph ), _result( result ), 
00046           _noOfNodesInIntMem( noOfNodesInIntMem ),
00047           _prefetchPool( DS_PQUEUE_PREFETCH_POOL ), _writePool( DS_PQUEUE_WRITE_POOL ),
00048           _pqueue(_prefetchPool, _writePool)
00049         {
00050             initPQueue();
00051             reduceNodes();
00052         }
00053     
00058     InternalMemoryBucket* getIntMemBucket() {return _firstExtBucket;}
00059 
00064     void add(const RelabeledEdge &edge);
00065     
00066  private:
00068     EdgeVector<Edge> &_graph;
00069 
00071     MST &_result;
00072 
00074     NodeCount _noOfNodesInIntMem;
00075 
00080     InternalMemoryBucket *_firstExtBucket;
00081     
00083     stxxl::prefetch_pool<PriorityQueue::block_type> _prefetchPool;
00084 
00086     stxxl::write_pool<PriorityQueue::block_type> _writePool;
00087 
00089     PriorityQueue _pqueue;
00090     
00095     void initPQueue();
00096 
00101     void reduceNodes();
00102 };
00103 
00104 
00109 inline void PQueue::add(const RelabeledEdge &edge)
00110 {
00111     if ( edge.isSelfLoop() ) return; // Self loops can be ignored.
00112     
00113     if (edge.source() < _noOfNodesInIntMem) {
00114         // add to the first external bucket
00115         _firstExtBucket->push_back( edge );
00116     }
00117     else {
00118         // add to the priority queue
00119         _pqueue.push( edge );
00120     }
00121 }
00122 
00123 
00124 #endif // PQUEUE_H

Generated on Thu Aug 14 15:13:27 2003 for External Memory Minimum Spanning Trees by doxygen1.2.17