Functions in different files
parent
2044c5c8eb
commit
bf0532867d
@ -0,0 +1,69 @@
|
||||
#include "MatchBoxPC.h"
|
||||
|
||||
/**
|
||||
* Execute the research fr the Candidate Mate without controlling if the vertices are already matched.
|
||||
* Returns the vertices with the highest weight
|
||||
* @param adj1
|
||||
* @param adj2
|
||||
* @param verLocInd
|
||||
* @param edgeLocWeight
|
||||
* @return
|
||||
*/
|
||||
inline MilanLongInt firstComputeCandidateMate(MilanLongInt adj1,
|
||||
MilanLongInt adj2,
|
||||
MilanLongInt* verLocInd,
|
||||
MilanReal* edgeLocWeight)
|
||||
{
|
||||
MilanInt w = -1;
|
||||
MilanReal heaviestEdgeWt = MilanRealMin; //Assign the smallest Value possible first LDBL_MIN
|
||||
int finalK;
|
||||
for (int k = adj1; k < adj2; k++) {
|
||||
|
||||
if ((edgeLocWeight[k] > heaviestEdgeWt) ||
|
||||
((edgeLocWeight[k] == heaviestEdgeWt) && (w < verLocInd[k]))) {
|
||||
heaviestEdgeWt = edgeLocWeight[k];
|
||||
w = verLocInd[k];
|
||||
finalK = k;
|
||||
}
|
||||
} //End of for loop
|
||||
return finalK;
|
||||
}
|
||||
|
||||
/**
|
||||
* //TODO documentation
|
||||
* @param adj1
|
||||
* @param adj2
|
||||
* @param edgeLocWeight
|
||||
* @param k
|
||||
* @param verLocInd
|
||||
* @param StartIndex
|
||||
* @param EndIndex
|
||||
* @param GMate
|
||||
* @param Mate
|
||||
* @param Ghost2LocalMap
|
||||
* @return
|
||||
*/
|
||||
inline MilanLongInt computeCandidateMate(MilanLongInt adj1,
|
||||
MilanLongInt adj2,
|
||||
MilanReal* edgeLocWeight,
|
||||
MilanLongInt k,
|
||||
MilanLongInt* verLocInd,
|
||||
MilanLongInt StartIndex,
|
||||
MilanLongInt EndIndex,
|
||||
vector <MilanLongInt>& GMate,
|
||||
MilanLongInt* Mate,
|
||||
map <MilanLongInt, MilanLongInt>& Ghost2LocalMap)
|
||||
{
|
||||
MilanInt w = -1;
|
||||
MilanReal heaviestEdgeWt = MilanRealMin; //Assign the smallest Value possible first LDBL_MIN
|
||||
for (k = adj1; k < adj2; k++) {
|
||||
if (isAlreadyMatched(verLocInd[k], StartIndex, EndIndex, GMate, Mate, Ghost2LocalMap)) continue;
|
||||
|
||||
if ((edgeLocWeight[k] > heaviestEdgeWt) ||
|
||||
((edgeLocWeight[k] == heaviestEdgeWt) && (w < verLocInd[k]))) {
|
||||
heaviestEdgeWt = edgeLocWeight[k];
|
||||
w = verLocInd[k];
|
||||
}
|
||||
} //End of for loop
|
||||
return w;
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
#include "MatchBoxPC.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
#include "primitiveDataTypeDefinitions.h"
|
||||
#include "dataStrStaticQueue.h"
|
||||
|
||||
///Find the owner of a ghost node:
|
||||
inline MilanInt findOwnerOfGhost(MilanLongInt vtxIndex, MilanLongInt *mVerDistance,
|
||||
MilanInt myRank, MilanInt numProcs) {
|
||||
//MilanLongInt Size = mVerDistance.size();
|
||||
MilanLongInt mStartInd = mVerDistance[myRank];
|
||||
MilanInt Start = 0;
|
||||
MilanInt End = numProcs;
|
||||
MilanInt Current = 0;
|
||||
|
||||
#if 0
|
||||
if ( vtxIndex < mStartInd )
|
||||
End = myRank;
|
||||
else
|
||||
Start = myRank;
|
||||
#endif
|
||||
|
||||
while ( Start <= End ) {
|
||||
Current = (End + Start)/2;
|
||||
//CASE-1:
|
||||
if ( mVerDistance[Current] == vtxIndex ) {
|
||||
while ( mVerDistance[Current+1] == vtxIndex ) {
|
||||
Current++;
|
||||
if ( Current == numProcs )
|
||||
return (-1);
|
||||
}
|
||||
return (Current);
|
||||
}
|
||||
else { //CASE 2:
|
||||
if ( mVerDistance[Current] > vtxIndex )
|
||||
End = Current - 1;
|
||||
else //CASE 3:
|
||||
Start = Current + 1;
|
||||
}
|
||||
} //End of While()
|
||||
if ( Current == 0 )
|
||||
return (Current);
|
||||
else {
|
||||
if ( mVerDistance[Current] > vtxIndex )
|
||||
return (Current-1);
|
||||
else
|
||||
return (Current);
|
||||
} //End of else
|
||||
return (-1); //It should not reach here!
|
||||
} //End of findOwnerOfGhost()
|
@ -0,0 +1,42 @@
|
||||
#include "MatchBoxPC.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
#include "primitiveDataTypeDefinitions.h"
|
||||
#include "dataStrStaticQueue.h"
|
||||
|
||||
/**
|
||||
* //TODO documentation
|
||||
* @param k
|
||||
* @param verLocInd
|
||||
* @param StartIndex
|
||||
* @param EndIndex
|
||||
* @param GMate
|
||||
* @param Mate
|
||||
* @param Ghost2LocalMap
|
||||
* @return
|
||||
*/
|
||||
inline bool isAlreadyMatched(MilanLongInt node,
|
||||
MilanLongInt StartIndex,
|
||||
MilanLongInt EndIndex,
|
||||
vector <MilanLongInt> &GMate,
|
||||
MilanLongInt* Mate,
|
||||
map <MilanLongInt, MilanLongInt> &Ghost2LocalMap
|
||||
) {
|
||||
|
||||
bool result = false;
|
||||
#pragma omp critical(Mate)
|
||||
{
|
||||
if ((node < StartIndex) || (node > EndIndex)) { //Is it a ghost vertex?
|
||||
if (GMate[Ghost2LocalMap[node]] >= 0)// Already matched
|
||||
result = true;
|
||||
} else { //A local vertex
|
||||
if (Mate[node - StartIndex] >= 0) // Already matched
|
||||
result = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
Loading…
Reference in New Issue