67 Monitor m(*
this,
"BuildAggregates");
70 const int myRank = graph.
GetComm()->getRank();
72 ArrayRCP<LO> vertex2AggId = aggregates.
GetVertex2AggId()->getDataNonConst(0);
73 ArrayRCP<LO> procWinner = aggregates.
GetProcWinner() ->getDataNonConst(0);
77 const int defaultConnectWeight = 100;
78 const int penaltyConnectWeight = 10;
80 std::vector<int> aggWeight (numLocalAggregates, 0);
81 std::vector<int> connectWeight(numRows, defaultConnectWeight);
82 std::vector<int> aggPenalties (numRows, 0);
90 for (
int k = 0; k < 2; k++) {
91 for (LO i = 0; i < numRows; i++) {
92 if (aggStat[i] !=
READY)
97 for (
int j = 0; j < neighOfINode.size(); j++) {
98 LO neigh = neighOfINode[j];
102 aggWeight[vertex2AggId[neigh]] += connectWeight[neigh];
105 int bestScore = -100000;
107 int bestConnect = -1;
109 for (
int j = 0; j < neighOfINode.size(); j++) {
110 LO neigh = neighOfINode[j];
113 int aggId = vertex2AggId[neigh];
114 int score = aggWeight[aggId] - aggPenalties[aggId];
116 if (score > bestScore) {
119 bestConnect = connectWeight[neigh];
121 }
else if (aggId == bestAggId && connectWeight[neigh] > bestConnect) {
122 bestConnect = connectWeight[neigh];
126 aggWeight[aggId] = 0;
130 if (bestScore >= 0) {
132 vertex2AggId[i] = bestAggId;
133 procWinner [i] = myRank;
135 numNonAggregatedNodes--;
137 aggPenalties[bestAggId]++;
138 connectWeight[i] = bestConnect - penaltyConnectWeight;