本文整理汇总了C++中TIntPrV::Clr方法的典型用法代码示例。如果您正苦于以下问题:C++ TIntPrV::Clr方法的具体用法?C++ TIntPrV::Clr怎么用?C++ TIntPrV::Clr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TIntPrV
的用法示例。
在下文中一共展示了TIntPrV::Clr方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetFqNmObjIdPrV
void TNmObjBs::GetFqNmObjIdPrV(
const TStr& TargetNmObjStr, TIntPrV& FqNmObjIdPrV) const {
//printf("Searching %s ...", TargetNmObjStr.CStr());
// get target named-object-id
int TargetNmObjId=GetNmObjId(TargetNmObjStr);
// collect target named-object frequencies
TIntIntH NmObjIdToFqH;
// traverse target named-object documents
int NmObjDocs=GetNmObjDocs(TargetNmObjId);
for (int NmObjDocIdN=0; NmObjDocIdN<NmObjDocs; NmObjDocIdN++){
// get document-id
int DocId=GetNmObjDocId(TargetNmObjId, NmObjDocIdN);
// traverse named-object in document
int DocNmObjs=GetDocNmObjs(DocId);
for (int DocNmObjN=0; DocNmObjN<DocNmObjs; DocNmObjN++){
// get named-object & frequency
int NmObjId; int TermFq;
GetDocNmObjId(DocId, DocNmObjN, NmObjId, TermFq);
// increment named-object document frequency
NmObjIdToFqH.AddDat(NmObjId)++;
}
}
// get & sort frequency table
FqNmObjIdPrV.Clr(); NmObjIdToFqH.GetDatKeyPrV(FqNmObjIdPrV);
FqNmObjIdPrV.Sort(false);
}
示例2: GetSorted_LinkWgtDstEntIdPrV
void TSkyGridEnt::GetSorted_LinkWgtDstEntIdPrV(
const uint64& MnTm, const double& TopWgtSumPrc, TIntPrV& LinkWgtDstEntIdPrV) const {
double AllLinkWgtSum=0;
TIntIntH DstEntIdLinkWgtH;
int LinkEnts=GetLinkEnts();
for (int LinkEntN=0; LinkEntN<LinkEnts; LinkEntN++){
int DstEntId=GetLinkEntId(LinkEntN);
int EntLinks=GetEntLinks(LinkEntN);
int EntLinkWgtSum=0;
for (int EntLinkN=0; EntLinkN<EntLinks; EntLinkN++){
const TSkyGridEntLinkCtx& EntLinkCtx=GetEntLinkCtx(LinkEntN, EntLinkN);
if (EntLinkCtx.Tm>=MnTm){
EntLinkWgtSum+=EntLinkCtx.LinkWgt;}
}
DstEntIdLinkWgtH.AddDat(DstEntId, EntLinkWgtSum);
AllLinkWgtSum+=EntLinkWgtSum;
}
LinkWgtDstEntIdPrV.Clr(); DstEntIdLinkWgtH.GetDatKeyPrV(LinkWgtDstEntIdPrV);
LinkWgtDstEntIdPrV.Sort(false);
// cut long-tail
if ((TopWgtSumPrc>0.0)&&(LinkWgtDstEntIdPrV.Len()>0)){
int TopLinkWgt=LinkWgtDstEntIdPrV[0].Val1;
if (TopLinkWgt>(3*AllLinkWgtSum)/LinkWgtDstEntIdPrV.Len()){
double CutWgtSum=AllLinkWgtSum*(1-TopWgtSumPrc);
int LastValN=LinkWgtDstEntIdPrV.Len()-1;
while ((LastValN>0)&&(CutWgtSum>0)){
CutWgtSum-=LinkWgtDstEntIdPrV[LastValN].Val1;
LastValN--;
}
LinkWgtDstEntIdPrV.Trunc(LastValN+1);
}
}
}
示例3: Get1CnComSzCnt
// Algorithm: Find all bridges, remove them from the graph, find largest component K
// now add all bridges that do not touch K, find connected components
void Get1CnComSzCnt(const PUNGraph& Graph, TIntPrV& SzCntV) {
//TCnCom::GetWccCnt(Graph, SzCntV); IAssertR(SzCntV.Len() == 1, "Graph is not connected.");
TIntPrV EdgeV;
GetEdgeBridges(Graph, EdgeV);
if (EdgeV.Empty()) { SzCntV.Clr(false); return; }
PUNGraph TmpG = TUNGraph::New();
*TmpG = *Graph;
for (int e = 0; e < EdgeV.Len(); e++) {
TmpG->DelEdge(EdgeV[e].Val1, EdgeV[e].Val2); }
TCnComV CnComV; GetWccs(TmpG, CnComV);
IAssert(CnComV.Len() >= 2);
const TIntV& MxWcc = CnComV[0].NIdV;
TIntSet MxCcSet(MxWcc.Len());
for (int i = 0; i < MxWcc.Len(); i++) {
MxCcSet.AddKey(MxWcc[i]); }
// create new graph: bridges not touching MxCc of G with no bridges
for (int e = 0; e < EdgeV.Len(); e++) {
if (! MxCcSet.IsKey(EdgeV[e].Val1) && ! MxCcSet.IsKey(EdgeV[e].Val2)) {
TmpG->AddEdge(EdgeV[e].Val1, EdgeV[e].Val2); }
}
GetWccSzCnt(TmpG, SzCntV);
for (int c = 0; c < SzCntV.Len(); c++) {
if (SzCntV[c].Val1 == MxCcSet.Len()) {
SzCntV.Del(c); break; }
}
}
示例4: GetSorted_DocsEntIdPrV
/////////////////////////////////////////////////
// SkyGrid-Base
void TSkyGridBs::GetSorted_DocsEntIdPrV(TIntPrV& DocsEntIdPrV){
TIntIntH EntIdToDocsH;
for (int EntId=0; EntId<GetEnts(); EntId++){
int Docs=GetEnt(EntId).GetDocIds();
EntIdToDocsH.AddDat(EntId, Docs);
}
DocsEntIdPrV.Clr(); EntIdToDocsH.GetDatKeyPrV(DocsEntIdPrV);
DocsEntIdPrV.Sort(false);
}
示例5: TriadGetTestTUNGraph
// Test GetTriadParticip
// Number of nodes with x number of triangles it participates in
TEST(triad, TestGetTriadParticip) {
// Test TUNGraph
PUNGraph GraphTUN = TriadGetTestTUNGraph();
TIntPrV TriadCntV;
TSnap::GetTriadParticip(GraphTUN, TriadCntV);
VerifyGetTriadParticip(TriadCntV);
// Test TNGraph which is same as undirected.
PNGraph GraphTN = TriadGetTestTNGraph();
TriadCntV.Clr();
TSnap::GetTriadParticip(GraphTN, TriadCntV);
VerifyGetTriadParticip(TriadCntV);
// Test TNEGraph which is same as undirected.
PNEGraph GraphTNE = TriadGetTestTNEGraph();
TriadCntV.Clr();
TSnap::GetTriadParticip(GraphTN, TriadCntV);
VerifyGetTriadParticip(TriadCntV);
}
示例6: GetNGramStrV
void TNGramBs::GetNGramStrV(
const TStr& HtmlStr, TStrV& NGramStrV, TIntPrV& NGramBEChXPrV) const {
TIntV NGramIdV; NGramStrV.Clr(); NGramBEChXPrV.Clr();
TNGramBs::GetNGramIdV(HtmlStr, NGramIdV, NGramBEChXPrV);
NGramStrV.Gen(NGramIdV.Len(), 0);
for (int NGramIdN=0; NGramIdN<NGramIdV.Len(); NGramIdN++){
TStr NGramStr=GetNGramStr(NGramIdV[NGramIdN]);
NGramStrV.Add(NGramStr);
}
}
示例7: SetActorCntryLangByMajority
// set actor's language and country
void TImdbNet::SetActorCntryLangByMajority() {
// set language
TIntPrV NIdToVal;
for (TNodeI NI = BegNI(); NI < EndNI(); NI++) {
if (! NI().IsActor()) { continue; }
IAssert(NI().GetLang() == 0); // no language set
IAssert(NI.GetInDeg() == 0); // actors point to movies
int Nbhs=0; TIntH LangCntH;
for (int e = 0; e < NI.GetOutDeg(); e++) {
LangCntH.AddDat(NI.GetOutNDat(e).GetLang()) += 1; Nbhs++; }
if (LangCntH.IsKey(0)) { Nbhs-=LangCntH.GetDat(0); LangCntH.GetDat(0)=0; }
LangCntH.SortByDat(false);
if (LangCntH.GetKey(0) == 0) { continue; }
if (LangCntH[0]*2 >= Nbhs) {
NIdToVal.Add(TIntPr(NI.GetId(), LangCntH.GetKey(0))); }
}
for (int i = 0; i < NIdToVal.Len(); i++) {
GetNDat(NIdToVal[i].Val1).Lang = NIdToVal[i].Val2; }
printf(" language set: %d\n", NIdToVal.Len());
int cnt=0;
for (TNodeI NI = BegNI(); NI < EndNI(); NI++) { if (NI().IsActor() && NI().GetLang()==0) cnt++; }
printf(" Actors NO language: %d\n\n", cnt);
// set country
NIdToVal.Clr(true);
for (TNodeI NI = BegNI(); NI < EndNI(); NI++) {
if (! NI().IsActor()) { continue; }
IAssert(NI().GetCntry() == 0); // no country set
IAssert(NI.GetInDeg() == 0); // actors point to movies
int Nbhs=0; TIntH CntryCntH;
for (int e = 0; e < NI.GetOutDeg(); e++) {
CntryCntH.AddDat(NI.GetOutNDat(e).GetCntry()) += 1; Nbhs++; }
if (CntryCntH.IsKey(0)) { Nbhs-=CntryCntH.GetDat(0); CntryCntH.GetDat(0)=0; }
CntryCntH.SortByDat(false);
if (CntryCntH.GetKey(0) == 0) { continue; }
if (CntryCntH[0]*2 >= Nbhs) {
NIdToVal.Add(TIntPr(NI.GetId(), CntryCntH.GetKey(0))); }
}
for (int i = 0; i < NIdToVal.Len(); i++) {
GetNDat(NIdToVal[i].Val1).Cntry = NIdToVal[i].Val2; }
printf(" country set: %d\n", NIdToVal.Len());
cnt=0;
for (TNodeI NI = BegNI(); NI < EndNI(); NI++) { if (NI().IsActor() && NI().GetCntry()==0) cnt++; }
printf(" Actors NO country: %d\n\n", cnt);
}