DataArrayInt *ret=DataArrayInt::New();
int nbNodesOld=getNumberOfNodes();
ret->alloc(nbNodesOld,1);
- std::fill(ret->getPointer(),ret->getPointer()+nbNodesOld,-1);
- int *retPtr=ret->getPointer();
- std::vector<int> commRemain(comm->getConstPointer(),comm->getConstPointer()+comm->getNumberOfTuples());
- std::vector<int> commIRemain(commIndex->getConstPointer(),commIndex->getConstPointer()+commIndex->getNumberOfTuples());
+ int *pt=ret->getPointer();
+ std::fill(pt,pt+nbNodesOld,-1);
+ int nbOfGrps=commIndex->getNumberOfTuples()-1;
+ const int *cIPtr=commIndex->getPointer();
+ const int *cPtr=comm->getPointer();
+ for(int i=0;i<nbOfGrps;i++)
+ pt[cPtr[cIPtr[i]]]=-(i+2);
int newNb=0;
for(int iNode=0;iNode<nbNodesOld;iNode++)
{
- if(retPtr[iNode]!=-1)
- continue;
- if(commRemain.empty())
+ if(pt[iNode]<0)
{
- retPtr[iNode]=newNb++;
- continue;
- }
- if(commRemain[0]!=iNode)
- retPtr[iNode]=newNb;
- else
- {
- for(std::vector<int>::const_iterator iNode2=commRemain.begin();
- iNode2!=commRemain.begin()+commIRemain[1];iNode2++)
- retPtr[*iNode2]=newNb;
- int delta=commIRemain[1];
- commRemain.erase(commRemain.begin(),commRemain.begin()+commIRemain[1]);
- commIRemain.erase(commIRemain.begin());
- std::transform(commIRemain.begin(),commIRemain.end(),commIRemain.begin(),std::bind2nd(std::minus<int>(),delta));
+ if(pt[iNode]==-1)
+ pt[iNode]=newNb++;
+ else
+ {
+ int grpId=-(pt[iNode]+2);
+ for(int j=cIPtr[grpId];j<cIPtr[grpId+1];j++)
+ pt[cPtr[j]]=newNb;
+ newNb++;
+ }
}
- newNb++;
}
newNbOfNodes=newNb;
return ret;