00001 00024 #ifndef METISNODE_H_ 00025 #define METISNODE_H_ 00026 00027 typedef int METISINT; 00028 typedef double METISDOUBLE; 00029 #include <stddef.h> 00030 #include <vector> 00031 #include <iostream> 00032 using namespace std; 00033 class MetisNode{ 00034 public: 00035 00036 MetisNode(int id, int weight){ 00037 init(); 00038 _id = id; 00039 _weight = weight; 00040 // _isMatched = false; 00041 } 00042 00043 MetisNode(int weight) { 00044 _id = -1; 00045 _weight = weight; 00046 init(); 00047 } 00048 00049 MetisNode() { 00050 _weight = 0; 00051 _id = -1; 00052 init(); 00053 } 00054 00055 void init(){ 00056 // _partEd = NULL; 00057 // _partIndex = NULL; 00058 // _partEd.resize(0); 00059 // _partIndex.resize(0); 00060 _edgeWgtSum = 0; 00061 _isBoundary = false; 00062 _gain = 0; 00063 _edegree = 0; 00064 _idegree = 0; 00065 _ndgrees = 0; 00066 _numEdges = 0; 00067 _partition = -1; 00068 } 00069 // MetisNode(const MetisNode& node) { 00070 // _id = node._id; 00071 // _weight = node._weight; 00072 // _edgeWgtSum = node._edgeWgtSum; 00073 // } 00074 00075 00076 // ~MetisNode(){ 00077 // if(_partEd!=NULL){ 00078 // delete[] _partEd; 00079 // _partEd = NULL; 00080 // } 00081 // if(_partIndex!=NULL){ 00082 // delete[] _partIndex; 00083 // _partIndex = NULL; 00084 // } 00085 // } 00086 00087 int getNodeId() { 00088 return _id; 00089 } 00090 00091 void setNodeId(int i) { 00092 _id = i; 00093 } 00094 00095 int getWeight() { 00096 return _weight; 00097 } 00098 00099 void setWeight(int weight) { 00100 _weight = weight; 00101 } 00102 00103 int getAdjWgtSum() { 00104 return _edgeWgtSum; 00105 } 00106 00107 void addEdgeWeight(int weight) { 00108 _edgeWgtSum += weight; 00109 } 00110 00111 void setAdjWgtSum(int sum) { 00112 _edgeWgtSum = sum; 00113 } 00114 00115 int getPartition() { 00116 return _partition; 00117 } 00118 00119 void setPartition(int part) { 00120 _partition = part; 00121 } 00122 00123 bool isBoundary() { 00124 return _isBoundary; 00125 } 00126 00127 void setBoundary(bool isBoundary) { 00128 _isBoundary = isBoundary; 00129 } 00130 00131 // void setMapTo(GNode mapTo) { 00132 // _mapTo = mapTo; 00133 // } 00134 00135 // GNode getMapTo() { 00136 // return _mapTo; 00137 // } 00138 00139 int getIdegree() { 00140 return _idegree; 00141 } 00142 00143 void setIdegree(int idegree) { 00144 _idegree = idegree; 00145 } 00146 00147 int getEdegree() { 00148 return _edegree; 00149 } 00150 00151 void setEdegree(int edegree) { 00152 _edegree = edegree; 00153 } 00154 00155 void swapEDAndID() { 00156 int temp = _idegree; 00157 _idegree = _edegree; 00158 _edegree = temp; 00159 } 00160 00161 int getGain() { 00162 return _gain; 00163 } 00164 00165 void updateGain() { 00166 _gain = _edegree - _idegree; 00167 } 00168 00169 // void setSubGraphMap(GNode map) { 00170 // _subGraphMapTo = map; 00171 // } 00172 // 00173 // GNode getSubGraphMap() { 00174 // return _subGraphMapTo; 00175 // } 00176 00177 int getNDegrees() { 00178 return _ndgrees; 00179 } 00180 00181 void setNDegrees(int degrees) { 00182 _ndgrees = degrees; 00183 } 00184 00185 int getNumEdges() { 00186 return _numEdges; 00187 } 00188 00189 void incNumEdges() { 00190 _numEdges++; 00191 } 00192 00193 // METISINT* getPartEd(){ 00194 // return _partEd; 00195 // } 00196 // 00197 // METISINT* getPartIndex(){ 00198 // return _partIndex; 00199 // } 00200 00201 vector<METISINT>& getPartEd(){ 00202 return _partEd; 00203 } 00204 00205 vector<METISINT>& getPartIndex(){ 00206 return _partIndex; 00207 } 00208 00209 void initPartEdAndIndex(int num){ 00210 // _partEd = new int[num]; 00211 // _partIndex = new int[num]; 00212 // if(_partEd == NULL){ 00213 // _partEd = new int[num]; //.resize(num); 00214 // _partIndex = new int[num]; 00215 // } 00216 _partEd.resize(num); 00217 _partIndex.resize(num); 00218 00219 for(int i=0;i<num;i++){ 00220 _partEd[i] = 0; 00221 _partIndex[i] = 0; 00222 } 00223 00224 } 00225 00226 private: 00227 METISINT _weight; 00228 METISINT _numEdges; 00229 //the sum of weights of its edges 00230 METISINT _edgeWgtSum; 00231 METISINT _partition; 00232 bool _isBoundary; 00233 // GNode _match; 00234 // bool _isMatched; 00235 // the node it maps to in the coarser graph 00236 // GNode _mapTo; 00237 00238 METISINT _id; 00239 // the sum of the weights of its edges connecting neighbors in its partition 00240 METISINT _idegree; 00241 // the sum of the weights of its edges connecting neighbors in the other partition 00242 METISINT _edegree; 00243 // if moving this node to the other partition, the reduced cut 00244 METISINT _gain; 00245 00246 // the node it mapped in the subgraph got by bisecting the current graph 00247 00248 //for kway partitioning 00249 METISINT _ndgrees; 00250 vector<METISINT> _partEd; 00251 vector<METISINT> _partIndex; 00252 // METISINT* _partEd; 00253 // METISINT* _partIndex; 00254 }; 00255 00256 #endif /* METISNODE_H_ */