本文整理汇总了C++中TIntV::DelLast方法的典型用法代码示例。如果您正苦于以下问题:C++ TIntV::DelLast方法的具体用法?C++ TIntV::DelLast怎么用?C++ TIntV::DelLast使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TIntV
的用法示例。
在下文中一共展示了TIntV::DelLast方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetBetweennessCentr
void GetBetweennessCentr(const PUNGraph& Graph, TIntFltH& NodeBtwH, TIntPrFltH& EdgeBtwH, const double& NodeFrac) {
TIntV NIdV; Graph->GetNIdV(NIdV);
if (NodeFrac < 1.0) { // calculate beetweenness centrality for a subset of nodes
NIdV.Shuffle(TInt::Rnd);
for (int i = int((1.0-NodeFrac)*NIdV.Len()); i > 0; i--) {
NIdV.DelLast(); }
}
GetBetweennessCentr(Graph, NIdV, NodeBtwH, true, EdgeBtwH, true);
}
示例2: RewireCmtyNID
/// rewire bipartite community affiliation graphs
void TAGMUtil::RewireCmtyNID(THash<TInt,TIntV >& CmtyVH, TRnd& Rnd) {
THash<TInt,TIntV > NewCmtyVH(CmtyVH.Len());
TIntV NDegV;
TIntV CDegV;
for (int i = 0; i < CmtyVH.Len(); i++) {
int CID = CmtyVH.GetKey(i);
for (int j = 0; j < CmtyVH[i].Len(); j++) {
int NID = CmtyVH[i][j];
NDegV.Add(NID);
CDegV.Add(CID);
}
}
TIntPrSet CNIDSet(CDegV.Len());
int c=0;
while (c++ < 15 && CDegV.Len() > 1) {
for (int i = 0; i < CDegV.Len(); i++) {
int u = Rnd.GetUniDevInt(CDegV.Len());
int v = Rnd.GetUniDevInt(NDegV.Len());
if (CNIDSet.IsKey(TIntPr(CDegV[u], NDegV[v]))) {
continue;
}
CNIDSet.AddKey(TIntPr(CDegV[u], NDegV[v]));
if (u == CDegV.Len() - 1) {
CDegV.DelLast();
} else {
CDegV[u] = CDegV.Last();
CDegV.DelLast();
}
if ( v == NDegV.Len() - 1) {
NDegV.DelLast();
} else {
NDegV[v] = NDegV.Last();
NDegV.DelLast();
}
}
}
for (int i = 0; i < CNIDSet.Len(); i++) {
TIntPr CNIDPr = CNIDSet[i];
IAssert(CmtyVH.IsKey(CNIDPr.Val1));
NewCmtyVH.AddDat(CNIDPr.Val1);
NewCmtyVH.GetDat(CNIDPr.Val1).Add(CNIDPr.Val2);
}
CmtyVH = NewCmtyVH;
}
示例3: InitUnigramTable
//Precompute unigram table using alias sampling method
void InitUnigramTable(TIntV& Vocab, TIntV& KTable, TFltV& UTable) {
double TrainWordsPow = 0;
double Pwr = 0.75;
TFltV ProbV(Vocab.Len());
for (int64 i = 0; i < Vocab.Len(); i++) {
ProbV[i]=TMath::Power(Vocab[i],Pwr);
TrainWordsPow += ProbV[i];
KTable[i]=0;
UTable[i]=0;
}
for (int64 i = 0; i < ProbV.Len(); i++) {
ProbV[i] /= TrainWordsPow;
}
TIntV UnderV;
TIntV OverV;
for (int64 i = 0; i < ProbV.Len(); i++) {
UTable[i] = ProbV[i] * ProbV.Len();
if ( UTable[i] < 1 ) {
UnderV.Add(i);
} else {
OverV.Add(i);
}
}
while(UnderV.Len() > 0 && OverV.Len() > 0) {
int64 Small = UnderV.Last();
int64 Large = OverV.Last();
UnderV.DelLast();
OverV.DelLast();
KTable[Small] = Large;
UTable[Large] = UTable[Large] + UTable[Small] - 1;
if (UTable[Large] < 1) {
UnderV.Add(Large);
} else {
OverV.Add(Large);
}
}
}