00001 /* 00002 * WeightOracle.h 00003 * 00004 * Created on: Dec 1, 2010 00005 * Author: bert 00006 * 00007 * WeightOracle objects are used to return weight values 00008 * given indices, they also store the index cache for the 00009 * maximum weights 00010 * Subclasses will implement different types of weights for 00011 * different edge definitions such as bipartite graphs or 00012 * unipartite graphs, with edge weights either explicitly 00013 * stored or via a weight function 00014 */ 00015 00016 #ifndef WEIGHTORACLE_H_ 00017 #define WEIGHTORACLE_H_ 00018 #include "utils.h" 00019 #include <pthread.h> 00020 #include "IntDoubleMap.h" 00021 00025 #define LOOKUP_CACHE_SIZE 100 00026 00033 class WeightOracle { 00034 public: 00035 WeightOracle(); 00036 virtual ~WeightOracle(); 00037 00041 void computeIndex(); 00042 00049 int getWeightIndex(int row, int rank); 00050 00057 double getIndexedWeight(int row, int rank); 00058 00066 double getWeight(int row, int col); 00067 00074 virtual double computeWeight(int row, int col); 00075 00080 virtual int getSize(); 00081 00086 int getCacheSize(); 00087 00092 void setCacheSize(int c); 00093 00094 00098 void printStatsString(); 00099 00100 private: 00101 bool indexComputed; 00102 int cacheSize; 00103 int indexSize; 00104 int ** index; 00105 double ** cache; 00106 int numThreads; 00107 00108 IntDoubleMap ** maps; 00109 }; 00110 00111 00112 00116 typedef struct { 00120 int start; 00124 int interval; 00128 double ** cache; 00132 int ** index; 00133 00137 int size; 00138 00142 int cacheSize; 00143 00147 WeightOracle * wo; 00148 } WOThreadParam; 00149 00150 void * WOThreadedUpdateRows(void * v); 00151 00152 #endif /* WEIGHTORACLE_H_ */