当前位置: 首页>>代码示例>>C++>>正文


C++ TIntPr函数代码示例

本文整理汇总了C++中TIntPr函数的典型用法代码示例。如果您正苦于以下问题:C++ TIntPr函数的具体用法?C++ TIntPr怎么用?C++ TIntPr使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了TIntPr函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: GenSmallWorld

/// Generates a small-world graph using the Watts-Strogatz model.
/// We assume a circle where each node creates links to NodeOutDeg other nodes. 
/// This way at the end each node is connected to 2*NodeOutDeg other nodes.
/// See: Collective dynamics of 'small-world' networks. Watts and Strogatz.
/// URL: http://research.yahoo.com/files/w_s_NATURE_0.pdf
PUNGraph GenSmallWorld(const int& Nodes, const int& NodeOutDeg, const double& RewireProb, TRnd& Rnd) {
  THashSet<TIntPr> EdgeSet(Nodes*NodeOutDeg);
  
  IAssertR(Nodes > NodeOutDeg, TStr::Fmt("Insufficient nodes for out degree, %d!", NodeOutDeg));
  for (int node = 0; node < Nodes; node++) {
    const int src = node;
    for (int edge = 1; edge <= NodeOutDeg; edge++) {
      int dst = (node+edge) % Nodes;      // edge to next neighbor
      if (Rnd.GetUniDev() < RewireProb) { // random edge
        dst = Rnd.GetUniDevInt(Nodes);
        while (dst == src || EdgeSet.IsKey(TIntPr(src, dst))) {
          dst = Rnd.GetUniDevInt(Nodes); }
      }
      EdgeSet.AddKey(TIntPr(src, dst));
    }
  }
  PUNGraph GraphPt = TUNGraph::New();
  TUNGraph& Graph = *GraphPt;
  Graph.Reserve(Nodes, EdgeSet.Len());
  int node;
  for (node = 0; node < Nodes; node++) {
    IAssert(Graph.AddNode(node) == node);
  }
  for (int edge = 0; edge < EdgeSet.Len(); edge++) {
    Graph.AddEdge(EdgeSet[edge].Val1, EdgeSet[edge].Val2);
  }
  Graph.Defrag();
  return GraphPt;
}
开发者ID:DumexVN,项目名称:RandomAggLargeWithSnap,代码行数:34,代码来源:ggen.cpp

示例2: if

/////////////////////////////////////////////////
// Top2 Friends network
void TTop2FriendNet::SetTop2() {
  Top2NIdH.Gen(Net->GetNodes());
  TFltIntPrV WgtNIdV;
  for (TWgtNet::TNodeI NI = Net->BegNI(); NI < Net->EndNI(); NI++) {
    WgtNIdV.Clr(false);
    for (int e = 0; e < NI.GetOutDeg(); e++) {
      WgtNIdV.Add(TFltIntPr(NI.GetOutEDat(e), NI.GetOutNId(e)));
    }
    WgtNIdV.Shuffle(TInt::Rnd); // so that ties are broken randomly
    WgtNIdV.Sort(false);
    if (WgtNIdV.Len() == 0) { Top2NIdH.AddDat(NI.GetId(), TIntPr(-1, -1)); }
    else if (WgtNIdV.Len() == 1) { Top2NIdH.AddDat(NI.GetId(), TIntPr(WgtNIdV[0].Val2, -1)); } 
    else if (WgtNIdV.Len() >= 2) {
      Top2NIdH.AddDat(NI.GetId(), TIntPr(WgtNIdV[0].Val2, WgtNIdV[1].Val2)); }
  }
  // create union find structure
  PNGraph Top1Net = GetTop1Net();
  Top1UF = TUnionFind(Top1Net->GetNodes());
  TCnComV CnComV; 
  TCnCom::GetWccs(Top1Net, CnComV);
  for (TWgtNet::TNodeI NI = Net->BegNI(); NI < Net->EndNI(); NI++) {
    Top1UF.Add(NI.GetId());
  }
  for (int c = 0; c < CnComV.Len(); c++) {
    for (int i = 1; i < CnComV[c].Len(); i++) {
      Top1UF.Union(CnComV[c][0], CnComV[c][i]); }
  }
}
开发者ID:Aleyasen,项目名称:Alaki,代码行数:30,代码来源:wgtnet.cpp

示例3: IAssert

void TLwLinkBs::AddLink(const int TermId1, int LinkTypeId, int TermId2){
  IAssert(Onto->GetTermBs()->IsTermId(TermId1));
  IAssert(Onto->GetLinkTypeBs()->IsLinkTypeId(LinkTypeId));
  IAssert(Onto->GetTermBs()->IsTermId(TermId2));
  FromTermIdToLinkTypeIdTermIdPrVH.AddDat(TermId1).Add(TIntPr(LinkTypeId, TermId2));
  IntoTermIdToLinkTypeIdTermIdPrVH.AddDat(TermId2).Add(TIntPr(LinkTypeId, TermId1));
}
开发者ID:Accio,项目名称:snap,代码行数:7,代码来源:ontolight.cpp

示例4: Err

void QuoteGraph::CompareUsingShingles(THash<TMd5Sig, TIntSet>& Shingles) {
  int Count = 0;
  int RealCount = 0;
  TVec<TMd5Sig> ShingleKeys;
  Shingles.GetKeyV(ShingleKeys);
  THashSet<TIntPr> EdgeCache;

  for (int i = 0; i < ShingleKeys.Len(); i++) {
    if (i % 100 == 0) {
      Err("Processed %d out of %d shingles, count = %d\n", i, ShingleKeys.Len(), Count);
    }
    TIntSet Bucket;
    Shingles.IsKeyGetDat(ShingleKeys[i], Bucket);

    for (TIntSet::TIter Quote1 = Bucket.BegI(); Quote1 < Bucket.EndI(); Quote1++) {
      TIntSet::TIter Quote1Copy = Quote1;
      Quote1Copy++;
      for (TIntSet::TIter Quote2 = Quote1Copy; Quote2 < Bucket.EndI(); Quote2++) {
        if (!EdgeCache.IsKey(TIntPr(Quote1.GetKey(), Quote2.GetKey())) && !EdgeCache.IsKey(TIntPr(Quote2.GetKey(), Quote1.GetKey()))) {
          EdgeCache.AddKey(TIntPr(Quote1.GetKey(), Quote2.GetKey()));
          EdgeCache.AddKey(TIntPr(Quote2.GetKey(), Quote1.GetKey()));
          RealCount++;
          AddEdgeIfSimilar(Quote1.GetKey(), Quote2.GetKey());
        }
      }
    }
    int Len = Bucket.Len() * (Bucket.Len() - 1) / 2;
    Count += Len;
  }
  fprintf(stderr, "NUMBER OF COMPARES: %d\n", Count);
  fprintf(stderr, "NUMBER OF REAL COMPARES: %d\n", RealCount);
}
开发者ID:snap-stanford,项目名称:curis-2012,代码行数:32,代码来源:quotegraph.cpp

示例5: LsV

double TStringKernel::KTrie2(const TIntV& s, const TIntV& t, const double& lb, const int& p, int m, const int& AlphN) {
    int ls = s.Len(), lt = t.Len();
    if (ls < p || lt < p) return 0.0;
    m = TInt::GetMn(m, ls-p, lt-p);

    TVec<TVec<TTrieNodeP> > LsV(AlphN), LtV(AlphN); 
    TIntV v(p), x(p+m); double Kern = 0.0;

    // precalculate weights
    TFltV lbV(m+1); lbV[0] = 1;
    for (int i = 0; i < p; i++) lbV[0] *= lb;
    for (int i = 1; i <= m; i++) lbV[i] = lb * lbV[i-1];
    
    for (int i = 0; i <= ls - p; i++) {
        int j = TInt::GetMn(ls, i+p+m);
        LsV[s[i]].Add(TTrieNodeP(TIntPr(i, j-i), 0, 0)); // i == 0 becasue strings start with 0 (not 1 as in Matlab!)
    }
    for (int i = 0; i <= lt - p; i++) {
        int j = TInt::GetMn(lt, i+p+m);
        LtV[t[i]].Add(TTrieNodeP(TIntPr(i, j-i), 0, 0)); // i == 0 becasue strings start with 0 (not 1 as in Matlab!)
    }

    for (int AlphC = 0; AlphC < AlphN; AlphC++) {
        v[0] = AlphC; 
        KTrieR2(s, t, LsV[AlphC], LtV[AlphC], v, 1, Kern, lbV, p, m, AlphN); //depth == 1, not 0 !!!!
    }

    return Kern;
}
开发者ID:Austindeadhead,项目名称:qminer,代码行数:29,代码来源:strkernel.cpp

示例6: while

// set Language and Country for movies that do not have the value set
// for every movie find the mojority language/country in 1-hop neighborhood and set it
void TImdbNet::SetLangCntryByMajority() {
  // set language
  while (true) {
    TIntPrV NIdToVal;
    for (TNodeI NI = BegNI(); NI < EndNI(); NI++) {
      if (NI().GetLang() != 0) { continue; }
      int Nbhs=0; TIntH LangCntH;
      for (int e = 0; e < NI.GetOutDeg(); e++) {
        LangCntH.AddDat(NI.GetOutNDat(e).GetLang()) += 1;  Nbhs++; }
      for (int e = 0; e < NI.GetInDeg(); e++) {
        LangCntH.AddDat(NI.GetInNDat(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))); }
    }
    if (NIdToVal.Empty()) { break; } // done
    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().GetLang()==0) cnt++; }
  printf(" NO language: %d\n\n", cnt);
  // set country
  while (true) {
    TIntPrV NIdToVal;
    for (TNodeI NI = BegNI(); NI < EndNI(); NI++) {
      if (NI().GetCntry() != 0) { continue; }
      int Nbhs=0; TIntH CntryCntH;
      for (int e = 0; e < NI.GetOutDeg(); e++) {
        CntryCntH.AddDat(NI.GetOutNDat(e).GetCntry()) += 1;  Nbhs++; }
      for (int e = 0; e < NI.GetInDeg(); e++) {
        CntryCntH.AddDat(NI.GetInNDat(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))); }
    }
    if (NIdToVal.Empty()) { break; } // done
    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().GetCntry()==0) cnt++; }
  printf(" NO country: %d\n\n", cnt);
}
开发者ID:SherlockYang,项目名称:Archive,代码行数:52,代码来源:imdbnet.cpp

示例7: TIntPr

// After MCMC, NID joins community CID.
void TAGMFit::JoinCom(const int& NID, const int& JoinCID) {
  TUNGraph::TNodeI NI = G->GetNI(NID);
  for (int e = 0; e < NI.GetDeg(); e++) {
    int VID = NI.GetNbrNId(e);
    if (NIDComVH.GetDat(VID).IsKey(JoinCID)) {
      TIntPr SrcDstNIDPr = TIntPr(TMath::Mn(NID,VID), TMath::Mx(NID,VID));
      EdgeComVH.GetDat(SrcDstNIDPr).AddKey(JoinCID);
      ComEdgesV[JoinCID]++;
    }
  }
  CIDNSetV[JoinCID].AddKey(NID);
  NIDComVH.GetDat(NID).AddKey(JoinCID);
  NIDCIDPrS.AddKey(TIntPr(NID, JoinCID));
}
开发者ID:RoyZhengGao,项目名称:CommunityEvaluation,代码行数:15,代码来源:agmfit.cpp

示例8: printf

void TNetInfBs::SetModels(const double& minalpha, const double& maxalpha, const double& minbeta, const double& maxbeta) {
	if (GroundTruth->GetNodes() == 0) {
		printf("Ground truth must be generated before running SetModels!\n");
		return;
	}

	// assign a different alpha to every node
	for (TNGraph::TEdgeI EI = GroundTruth->BegEI(); EI < GroundTruth->EndEI(); EI++) {
		Alphas.AddDat(TIntPr(EI.GetSrcNId(), EI.GetDstNId())) = minalpha + (double)TFlt::Rnd.GetUniDev() * (maxalpha-minalpha);
		Betas.AddDat(TIntPr(EI.GetSrcNId(), EI.GetDstNId())) = minbeta + (double)TFlt::Rnd.GetUniDev() * (maxbeta-minbeta);

	// printf("Edge:(%d,%d) alpha:%f beta:%f\n", EI.GetSrcNId(), EI.GetDstNId(), Alphas.GetDat(TIntPr(EI.GetSrcNId(), EI.GetDstNId())).Val, Betas.GetDat(TIntPr(EI.GetSrcNId(), EI.GetDstNId())).Val);
	}
}
开发者ID:blizzardwj,项目名称:ML_netinf,代码行数:14,代码来源:cascinf.cpp

示例9: fprintf

void TCycBs::_SaveTaxonomyTxt(FILE* fOut, 
 const int& Lev, TIntPrV& RelIdVIdPrV, TIntIntH& VIdToLevH){
  for (int VidN=0; VidN<RelIdVIdPrV.Len(); VidN++){
    int FromRelId=RelIdVIdPrV[VidN].Val1;
    int SrcVId=RelIdVIdPrV[VidN].Val2;
    TStr SrcVNm=GetVNm(SrcVId);
    TCycVrtx& SrcVrtx=GetVrtx(SrcVId);
    if (!SrcVrtx.IsFlag(cvfHumanOk)){continue;}
    TStr FlagStr=SrcVrtx.GetFlagStr();
    if (FromRelId==-1){
      if (Lev>0){fprintf(fOut, "===upper");} else {fprintf(fOut, "===lower");}
      fprintf(fOut, "=======================================================\n");
      fprintf(fOut, "%s - %s\n", SrcVNm.CStr(), FlagStr.CStr());
    } else {
      TStr FromRelNm=GetVNm(FromRelId);
      fprintf(fOut, "%*c[%s] --> %s\n", (Lev-1)*5, ' ', FromRelNm.CStr(), SrcVNm.CStr());
    }
    TIntPrV UpRelIdVIdPrV;
    for (int EdgeN=0; EdgeN<SrcVrtx.GetEdges(); EdgeN++){
      TCycEdge& Edge=SrcVrtx.GetEdge(EdgeN);
      int RelId=Edge.GetRelId();
      int DstVId=Edge.GetDstVId();
      TStr RelNm=GetVNm(RelId);
      TStr DstVNm=GetVNm(DstVId);
      if (Lev>0){
        // upper taxonomy
        if ((RelNm=="#$isa")||(RelNm=="#$genls")){
          if (!VIdToLevH.IsKey(DstVId)){
            VIdToLevH.AddDat(DstVId, Lev+1);
            UpRelIdVIdPrV.Add(TIntPr(RelId, DstVId));
          }
        }
      } else {
        // lower taxonomy
        if ((RelNm=="~#$isa")||(RelNm=="~#$genls")){
          if (!VIdToLevH.IsKey(DstVId)){
            VIdToLevH.AddDat(DstVId, Lev-1);
            UpRelIdVIdPrV.Add(TIntPr(RelId, DstVId));
          }
        }
      }
    } 
    // recursive call
    if (Lev>0){
      _SaveTaxonomyTxt(fOut, Lev+1, UpRelIdVIdPrV, VIdToLevH);
    } else {
      _SaveTaxonomyTxt(fOut, Lev-1, UpRelIdVIdPrV, VIdToLevH);
    }
  }
}
开发者ID:mkarlovc,项目名称:gcentralization,代码行数:50,代码来源:cyc.cpp

示例10: NewEdgeSet

void TAGM::RndConnectInsideCommunity(PUNGraph& Graph, const TIntV& CmtyV, const double& Prob, TRnd& Rnd){
	int CNodes = CmtyV.Len();
	int CEdges = Rnd.GetBinomialDev(Prob,CNodes*(CNodes-1)/2);
	THashSet<TIntPr> NewEdgeSet(CEdges);
	for (int edge = 0; edge < CEdges; ) {
		int SrcNId = CmtyV[Rnd.GetUniDevInt(CNodes)];
		int DstNId = CmtyV[Rnd.GetUniDevInt(CNodes)];
		if(SrcNId>DstNId){Swap(SrcNId,DstNId);}
		if (SrcNId != DstNId && !NewEdgeSet.IsKey(TIntPr(SrcNId,DstNId))) { // is new edge
			NewEdgeSet.AddKey(TIntPr(SrcNId,DstNId));
			Graph->AddEdge(SrcNId,DstNId);
			edge++; 
		} 
	}
}
开发者ID:Networks-Learning,项目名称:infopath,代码行数:15,代码来源:agm.cpp

示例11: InitItemSets

TIntPrV TTrawling::PlotMinFqVsMaxSet(const TStr& OutFNm) {
  InitItemSets();
  TIntPrV SzCntH;
  SzCntH.Add(TIntPr(1, CurItemH.Len()));
  for (int ItemSetSz = 2; ItemSetSz < 100; ItemSetSz++) {
    printf("\nItemset size %d:  ", ItemSetSz);
    GetNextFqItemSets();
    if (CurItemH.Empty()) { break; }
    SzCntH.Add(TIntPr(ItemSetSz, CurItemH.Len()));
    TGnuPlot::PlotValV(SzCntH, "itemSet-"+OutFNm, TStr::Fmt("Minimum Suport = %d", MinSup),
      "Itemset size", "Number of itemsets > Minimum Support");
  }
  printf("\n\n");
  return SzCntH;
}
开发者ID:Aleyasen,项目名称:Alaki,代码行数:15,代码来源:trawling.cpp

示例12: WordIdToFirstDocIdNH

/////////////////////////////////////////////////
// Yahoo-Inverted-Index
TYInvIx::TYInvIx(
 const double& EstExp, const double& SumEstPrb,
 const PYBs& YBs, const PYDsBs& YDsBs,
 const PYFSelBs& YFSelBs, const PNotify& Notify):
  WordIdToFirstDocIdNH(YBs->GetWords()/2),
  DocIdVHeap(), AllDocIdV(YBs->GetDocs(), 0){
  TNotify::OnNotify(Notify, ntInfo, "Start Creating Inverted Index");
  TIntPrV WordIdDocIdPrV(YBs->GetDocs(), 0);
  TIntV BestWordIdV;
  int DocId=YBs->FFirstDocId();
  while (YBs->FNextDocId(DocId)){
    AllDocIdV.Add(DocId);
    PYWordDs PosWordDs=YDsBs->GetWordDs(DocId);
    YFSelBs->GetBestWordIdV(DocId, EstExp, SumEstPrb, PosWordDs, BestWordIdV);
    for (int WordIdN=0; WordIdN<BestWordIdV.Len(); WordIdN++){
      int WordId=BestWordIdV[WordIdN];
      WordIdDocIdPrV.Add(TIntPr(WordId, DocId));
    }
  }
  WordIdDocIdPrV.Sort();
  DocIdVHeap.Gen(WordIdDocIdPrV.Len()+YBs->GetDocs(), 0);
  int PrevWordId=-1;
  for (int WordIdN=0; WordIdN<WordIdDocIdPrV.Len(); WordIdN++){
    int WordId=WordIdDocIdPrV[WordIdN].Val1;
    int DocId=WordIdDocIdPrV[WordIdN].Val2;
    if (PrevWordId!=WordId){
      if (PrevWordId!=-1){DocIdVHeap.Add(TInt(-1));}
      PrevWordId=WordId;
      WordIdToFirstDocIdNH.AddDat(TInt(WordId), TInt(DocIdVHeap.Len()));
    }
    DocIdVHeap.Add(DocId);
  }
  DocIdVHeap.Add(TInt(-1));
  TNotify::OnNotify(Notify, ntInfo, "End Creating Inverted Index");
}
开发者ID:mkarlovc,项目名称:gcentralization,代码行数:37,代码来源:yahoodm.cpp

示例13: GetNI

// actors collaboration graph
PUNGraph TImdbNet::GetActorGraph() const  { 
  TIntPrSet EdgeSet;
  for (TNodeI NI = BegNI(); NI < EndNI(); NI++) {
    if (NI().GetTy() == mtyActor) {
      const int NId1 = NI.GetId();
      for (int e = 0; e < NI.GetOutDeg(); e++) {
        if (NI.GetOutNDat(e).GetTy() != mtyActor) {
          TNodeI NI2 = GetNI(NI.GetOutNId(e));
          for (int e2 = 0; e2 < NI2.GetInDeg(); e2++) {
            if (NI2.GetInNDat(e2).GetTy() == mtyActor) {
              const int NId2 = NI2.GetInNId(e2);
              EdgeSet.AddKey(TIntPr(TMath::Mn(NId1, NId2), TMath::Mx(NId1, NId2)));
            }
          }
        }
      }
    }
  }
  PUNGraph G = TUNGraph::New(); 
  for (int i = 0; i < EdgeSet.Len(); i++) {
    const int NId1 = EdgeSet[i].Val1;
    const int NId2 = EdgeSet[i].Val2;
    if (! G->IsNode(NId1)) { G->AddNode(NId1); }
    if (! G->IsNode(NId2)) { G->AddNode(NId2); }
    G->AddEdge(NId1, NId2);
  }
  return G;
}
开发者ID:SherlockYang,项目名称:Archive,代码行数:29,代码来源:imdbnet.cpp

示例14: NewNmObjIdToFqH

void TNmObjBs::PutMergedNmObj(const TIntV& NewNmObjIdV){
  // create temporary table of new named-objects
  TStrVIntVH NewNmObjWordStrVToDocIdVH;
  for (int NmObjId=0; NmObjId<NewNmObjIdV.Len(); NmObjId++){
    if (NewNmObjIdV[NmObjId]!=NmObjId){continue;}
    // take data for new named-object from old definition
    const TStrV& WordStrV=NmObjWordStrVToDocIdVH.GetKey(NmObjId);
    // define new named-object
    NewNmObjWordStrVToDocIdVH.AddDat(WordStrV);
  }
  //printf("Old Named-Objects: %d\n", NmObjWordStrVToDocIdVH.Len());
  //printf("New Named-Objects: %d\n", NewNmObjWordStrVToDocIdVH.Len());
  // obsolete named-object define as aliases
  {for (int NmObjId=0; NmObjId<NewNmObjIdV.Len(); NmObjId++){
    if (NewNmObjIdV[NmObjId]==NmObjId){continue;}
    // take data for obsolete named-object from old definition
    const TStrV& WordStrV=NmObjWordStrVToDocIdVH.GetKey(NmObjId);
    // define alias for obsolete named-object
    int NrNmObjId=NewNmObjIdV[NmObjId];
    if (NrNmObjId!=-1){
      const TStrV& NrWordStrV=NmObjWordStrVToDocIdVH.GetKey(NrNmObjId);
      NmObjWordStrVToNrH.AddDat(WordStrV, NrWordStrV);
    }
  }}
  // redefine documents
  int Docs=GetDocs();
  for (int DocId=0; DocId<Docs; DocId++){
    TIntPrV& NmObjIdFqPrV=GetDoc_NmObjIdFqPrV(DocId);
    // create temporary-document: new-named-object to frequency table
    TIntIntH NewNmObjIdToFqH(NmObjIdFqPrV.Len());
    for (int NmObjN=0; NmObjN<NmObjIdFqPrV.Len(); NmObjN++){
      // get obsolete named-object data
      int NmObjId=NmObjIdFqPrV[NmObjN].Val1;
      int Fq=NmObjIdFqPrV[NmObjN].Val2;
      // get named-document-id for normalized named-object
      int NrNmObjId=NewNmObjIdV[NmObjId];
      if (NrNmObjId!=-1){
        // get normalized version of word-vector
        const TStrV& NrWordStrV=NmObjWordStrVToDocIdVH.GetKey(NrNmObjId);
        // get new named-object-id
        int NewNmObjId=NewNmObjWordStrVToDocIdVH.GetKeyId(NrWordStrV);
        // add new named-object-id and term-frequency to temporary-document
        NewNmObjIdToFqH.AddDat(NewNmObjId)+=Fq;
      }
    }
    // transfere new-named-object data to document
    NmObjIdFqPrV.Gen(NewNmObjIdToFqH.Len(), 0);
    for (int NmObjP=0; NmObjP<NewNmObjIdToFqH.Len(); NmObjP++){
      int NewNmObjId=NewNmObjIdToFqH.GetKey(NmObjP);
      int Fq=NewNmObjIdToFqH[NmObjP];
      // add named-object and increment by term-frequency
      NmObjIdFqPrV.Add(TIntPr(NewNmObjId, Fq));
      // merge document-ids
      NewNmObjWordStrVToDocIdVH[NewNmObjId].Add(DocId);
    }
    NmObjIdFqPrV.Sort();
  }
  // assign new named-objects
  NmObjWordStrVToDocIdVH=NewNmObjWordStrVToDocIdVH;
}
开发者ID:AlertProject,项目名称:Text-processing-bundle,代码行数:60,代码来源:nmobj.cpp

示例15: printf

TFfGGen::TStopReason TUndirFFire::AddNodes(const int& GraphNodes, const bool& FloodStop) {
	printf("\n***Undirected GEO ForestFire: graph(%d,%d) add %d nodes, burn prob %.3f\n",
		Graph->GetNodes(), Graph->GetEdges(), GraphNodes, BurnProb);
	TExeTm ExeTm;
	int Burned1 = 0, Burned2 = 0, Burned3 = 0; // last 3 fire sizes
	TIntPrV NodesEdgesV;
	// create initial set of nodes
	if (Graph.Empty()) { Graph = PUNGraph::New(); }
	if (Graph->GetNodes() == 0) { Graph->AddNode(); }
	int NEdges = Graph->GetEdges();
	// forest fire
	for (int NNodes = Graph->GetNodes() + 1; NNodes <= GraphNodes; NNodes++) {
		const int NewNId = Graph->AddNode(-1);
		IAssert(NewNId == Graph->GetNodes() - 1); // node ids have to be 0...N
		const int StartNId = Rnd.GetUniDevInt(NewNId);
		const int NBurned = BurnGeoFire(StartNId);
		// add edges to burned nodes
		for (int e = 0; e < NBurned; e++) {
			Graph->AddEdge(NewNId, GetBurnedNId(e));
		}
		NEdges += NBurned;
		Burned1 = Burned2;  Burned2 = Burned3;  Burned3 = NBurned;
		if (NNodes % Kilo(1) == 0) {
			printf("(%d, %d)    burned: [%d,%d,%d]  [%s]\n", NNodes, NEdges, Burned1, Burned2, Burned3, ExeTm.GetStr());
			NodesEdgesV.Add(TIntPr(NNodes, NEdges));
		}
		if (FloodStop && NEdges>1000 && NEdges / double(NNodes)>100.0) { // average node degree is more than 50
			printf("!!! FLOOD. G(%6d, %6d)\n", NNodes, NEdges);  return TFfGGen::srFlood;
		}
	}
	printf("\n");
	IAssert(Graph->GetEdges() == NEdges);
	return TFfGGen::srOk;
}
开发者ID:Austindeadhead,项目名称:qminer,代码行数:34,代码来源:ff.cpp


注:本文中的TIntPr函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。