00001 00024 #ifndef RM_H_ 00025 #define RM_H_ 00026 00029 class RMMatcher{ 00030 private: 00031 int maxVertexWeight; 00032 GGraph* graph; 00033 GGraph* coarseGraph; 00034 MetisGraph* metisGraph; 00035 public: 00036 RMMatcher(MetisGraph* metisGraph, GGraph* coarseGraph, int maxVertexWeight) { 00037 this->coarseGraph=coarseGraph; 00038 this->metisGraph = metisGraph; 00039 this->graph=metisGraph->getGraph(); 00040 this->maxVertexWeight=maxVertexWeight; 00041 } 00042 /* 00043 void match(GNode node) { 00044 MetisNode& nodeData = node.getData(Galois::CHECK_CONFLICT); 00045 if (metisGraph->isMatched(nodeData.getNodeId())) { 00046 return; 00047 } 00048 GNode matchNode = node; 00049 for (GGraph::neighbor_iterator jj = graph->neighbor_begin(node, Galois::CHECK_CONFLICT), eejj = graph->neighbor_end(node, Galois::CHECK_CONFLICT); jj != eejj; ++jj) { 00050 GNode neighbor = *jj; 00051 MetisNode& neighMNode = neighbor.getData(Galois::NONE); 00052 if (!metisGraph->isMatched(neighMNode.getNodeId()) && nodeData.getWeight() + neighMNode.getWeight() <= maxVertexWeight) { 00053 matchNode = neighbor; 00054 break; 00055 } 00056 } 00057 00058 MetisNode& matchNodeData = matchNode.getData(Galois::NONE); 00059 00060 metisGraph->setMatch(nodeData.getNodeId(), matchNode); 00061 00062 int weight = nodeData.getWeight(); 00063 if (node != matchNode) { 00064 metisGraph->setMatch(matchNodeData.getNodeId(), node); 00065 weight += matchNodeData.getWeight(); 00066 } 00067 <<<<<<< .mine 00068 // GNode newNode = coarseGraph->createNode(MetisNode(weight)); 00069 // coarseGraph->addNode(newNode, Galois::Graph::NONE); 00070 // metisGraph->setCoarseGraphMap(nodeData.getNodeId(), newNode); 00071 // if(matchNode!=node){ 00072 // metisGraph->setCoarseGraphMap(matchNodeData.getNodeId(), newNode); 00073 // } 00074 ======= 00075 GNode newNode = coarseGraph->createNode(MetisNode(weight)); 00076 coarseGraph->addNode(newNode, Galois::NONE); 00077 metisGraph->setCoarseGraphMap(nodeData.getNodeId(), newNode); 00078 metisGraph->setCoarseGraphMap(matchNodeData.getNodeId(), newNode); 00079 >>>>>>> .r7421 00080 } 00081 */ 00082 void match(GNode node) { 00083 MetisNode& nodeData = node.getData(Galois::NONE); 00084 if (metisGraph->isMatched(nodeData.getNodeId())) { 00085 return; 00086 } 00087 GNode matchNode; 00088 while(true){ 00089 matchNode = node; 00090 for (GGraph::neighbor_iterator jj = graph->neighbor_begin(node, Galois::NONE), eejj = graph->neighbor_end(node, Galois::NONE); jj != eejj; ++jj) { 00091 GNode neighbor = *jj; 00092 MetisNode& neighMNode = neighbor.getData(Galois::NONE); 00093 if (!metisGraph->isMatched(neighMNode.getNodeId()) && nodeData.getWeight() + neighMNode.getWeight() <= maxVertexWeight) { 00094 matchNode = neighbor; 00095 break; 00096 } 00097 } 00098 00099 MetisNode& matchNodeData = matchNode.getData(Galois::CHECK_CONFLICT); 00100 if(node == matchNode || !metisGraph->isMatched(matchNodeData.getNodeId())){ 00101 break; 00102 } 00103 } 00104 node.getData(Galois::CHECK_CONFLICT); 00105 if(metisGraph->isMatched(nodeData.getNodeId())){ 00106 return; 00107 } 00108 00109 metisGraph->setMatch(nodeData.getNodeId(), matchNode); 00110 MetisNode& matchNodeData = matchNode.getData(Galois::NONE); 00111 // int weight = nodeData.getWeight(); 00112 if (node != matchNode) { 00113 metisGraph->setMatch(matchNodeData.getNodeId(), node); 00114 // weight += matchNodeData.getWeight(); 00115 } 00116 // GNode newNode = coarseGraph->createNode(MetisNode(weight)); 00117 // coarseGraph->addNode(newNode, Galois::Graph::NONE); 00118 // metisGraph->setCoarseGraphMap(nodeData.getNodeId(), newNode); 00119 // if(matchNode!=node){ 00120 // metisGraph->setCoarseGraphMap(matchNodeData.getNodeId(), newNode); 00121 // } 00122 } 00123 00124 00125 }; 00126 #endif /* RM_H_ */