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


C++ TIntV::Clr方法代码示例

本文整理汇总了C++中TIntV::Clr方法的典型用法代码示例。如果您正苦于以下问题:C++ TIntV::Clr方法的具体用法?C++ TIntV::Clr怎么用?C++ TIntV::Clr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TIntV的用法示例。


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

示例1: GetAllStaticTriangles

void TempMotifCounter::GetAllStaticTriangles(TIntV& Us, TIntV& Vs, TIntV& Ws) {
  Us.Clr();
  Vs.Clr();
  Ws.Clr();
  // Get degree ordering of the graph
  int max_nodes = static_graph_->GetMxNId();
  TVec<TIntPair> degrees(max_nodes);
  degrees.PutAll(TIntPair(0, 0));
  // Set the degree of a node to be the number of nodes adjacent to the node in
  // the undirected graph.
  TIntV nodes;
  GetAllNodes(nodes);
  #pragma omp parallel for schedule(dynamic)  
  for (int node_id = 0; node_id < nodes.Len(); node_id++) {
    int src = nodes[node_id];
    TIntV nbrs;
    GetAllNeighbors(src, nbrs);
    degrees[src] = TIntPair(nbrs.Len(), src);
  }
  degrees.Sort();
  TIntV order = TIntV(max_nodes);
  #pragma omp parallel for schedule(dynamic)  
  for (int i = 0; i < order.Len(); i++) {
    order[degrees[i].Dat] = i;
  }

  // Get triangles centered at a given node where that node is the smallest in
  // the degree ordering.
  #pragma omp parallel for schedule(dynamic)  
  for (int node_id = 0; node_id < nodes.Len(); node_id++) {
    int src = nodes[node_id];
    int src_pos = order[src];
    
    // Get all neighbors who come later in the ordering
    TIntV nbrs;
    GetAllNeighbors(src, nbrs);    
    TIntV neighbors_higher;
    for (int i = 0; i < nbrs.Len(); i++) {
      int nbr = nbrs[i];
      if (order[nbr] > src_pos) { neighbors_higher.Add(nbr); }
    }

    for (int ind1 = 0; ind1 < neighbors_higher.Len(); ind1++) {
      for (int ind2 = ind1 + 1; ind2 < neighbors_higher.Len(); ind2++) {
        int dst1 = neighbors_higher[ind1];
        int dst2 = neighbors_higher[ind2];
        // Check for triangle formation
        if (static_graph_->IsEdge(dst1, dst2) || static_graph_->IsEdge(dst2, dst1)) {
          #pragma omp critical
          {
            Us.Add(src);
            Vs.Add(dst1);
            Ws.Add(dst2);
          }
        }
      }
    }
  }
}
开发者ID:jsw883,项目名称:snap,代码行数:59,代码来源:temporalmotifs.cpp

示例2: grafoGDF

void grafoGDF(PUNGraph G) {
  
  std::ofstream myfile;
  std::vector<int> nodos = obtenerVerticesOrdenados(G);
  TIntV conexiones;
  
  myfile.open("facebook.gdf");
  
  myfile << "nodedef>name VARCHAR" << "\n";
  myfile << "edgedef>node1 VARCHAR,node2 VARCHAR" << "\n";
  
  for (int i = 0; i < nodos.size(); i++) {
    
    GetNodesAtHop(G, nodos[i], 1, conexiones, false);
    
    for (int j = 0; j < conexiones.EndI() - conexiones.BegI(); j++) {
      if (conexiones[j] > i) {
        myfile << i << "," << conexiones[j] << "\n";
      }
    }
    
    conexiones.Clr();
    
  }
  
  myfile.close();
  
}//cierre de grafoGDF
开发者ID:yocoHM,项目名称:grafosGephi,代码行数:28,代码来源:main.cpp

示例3: MinSup

/////////////////////////////////////////////////
// Trawling the web for emerging communities
// graph, left points to right
TTrawling::TTrawling(const PNGraph& Graph, const int& MinSupport) : MinSup(MinSupport) {
  TIntH ItemCntH;
  for (TNGraph::TNodeI NI = Graph->BegNI(); NI < Graph->EndNI(); NI++) {
    IAssert(NI.GetOutDeg()==0 || NI.GetInDeg()==0); // edges only point from left to right
    if (NI.GetOutDeg()==0) { continue; }
    for (int e = 0; e < NI.GetOutDeg(); e++) {
      ItemCntH.AddDat(NI.GetOutNId(e)) += 1;
    }
  }

  TIntV RightV;
  for (TNGraph::TNodeI NI = Graph->BegNI(); NI < Graph->EndNI(); NI++) {
    IAssert(NI.GetOutDeg()==0 || NI.GetInDeg()==0); // edges only point from left to right
    if (NI.GetOutDeg()==0) { continue; }
    RightV.Clr(false);
    for (int e = 0; e < NI.GetOutDeg(); e++) {
      const int itm = NI.GetOutNId(e);
      // only include items that already are above minimum support
      if (ItemCntH.GetDat(itm) >= MinSup) {
        RightV.Add(itm); }
    }
    if (! RightV.Empty()) {
      NIdSetH.AddDat(NI.GetId(), RightV);
    }
  }
  //
  for (int n = 0; n < NIdSetH.Len(); n++) {
    const TIntV& Set = NIdSetH[n];
    for (int s = 0; s < Set.Len(); s++) {
      SetNIdH.AddDat(Set[s]).Add(n);
    }
  }
}
开发者ID:Aleyasen,项目名称:Alaki,代码行数:36,代码来源:trawling.cpp

示例4: GetWordUStrV

void TUStr::GetWordUStrV(TUStrV& WordUStrV){
  // clear word vector
  WordUStrV.Clr();
  // create boundaries
  TBoolV WordBoundPV; GetWordBoundPV(WordBoundPV);
  IAssert(Len()==WordBoundPV.Len()-1);
  IAssert((WordBoundPV.Len()>0)&&(WordBoundPV.Last()));
  // traverse characters and bounds
  int UniChs=Len(); TIntV WordUniChV;
  for (int UniChN=0; UniChN<=UniChs; UniChN++){
    if ((UniChN==UniChs)||(WordBoundPV[UniChN+1])){ // finish or word-boundary
      if (UniChN<UniChs){ // if not finish
        // if last-word-char or single-alphabetic-char
        if ((!WordUniChV.Empty())||(IsAlphabetic(UniChV[UniChN]))){
          WordUniChV.Add(UniChV[UniChN]); // add char
        }
      }
      if (!WordUniChV.Empty()){ // add current word to vector
        TUStr WordUStr(WordUniChV); // construct word from char-vector
        WordUStrV.Add(WordUStr); // add word to word-vector
        WordUniChV.Clr(false); // clear char-vector
      }
    } else {
      // add character to char-vector
      WordUniChV.Add(UniChV[UniChN]);
    }
  }
}
开发者ID:RoyZhengGao,项目名称:CommunityEvaluation,代码行数:28,代码来源:unicodestring.cpp

示例5: BurnExpFire

// burn each link independently (forward with FwdBurnProb, backward with BckBurnProb)
void TForestFire::BurnExpFire() {
  const double OldFwdBurnProb = FwdBurnProb;
  const double OldBckBurnProb = BckBurnProb;
  const int NInfect = InfectNIdV.Len();
  const TNGraph& G = *Graph;
  TIntH BurnedNIdH;               // burned nodes
  TIntV BurningNIdV = InfectNIdV; // currently burning nodes
  TIntV NewBurnedNIdV;            // nodes newly burned in current step
  bool HasAliveNbrs;              // has unburned neighbors
  int NBurned = NInfect, NDiedFire=0;
  for (int i = 0; i < InfectNIdV.Len(); i++) {
    BurnedNIdH.AddDat(InfectNIdV[i]); }
  NBurnedTmV.Clr(false);  NBurningTmV.Clr(false);  NewBurnedTmV.Clr(false);
  for (int time = 0; ; time++) {
    NewBurnedNIdV.Clr(false);
    // for each burning node
    for (int node = 0; node < BurningNIdV.Len(); node++) {
      const int& BurningNId = BurningNIdV[node];
      const TNGraph::TNodeI Node = G.GetNI(BurningNId);
      HasAliveNbrs = false;
      NDiedFire = 0;
      // burn forward links  (out-links)
      for (int e = 0; e < Node.GetOutDeg(); e++) {
        const int OutNId = Node.GetOutNId(e);
        if (! BurnedNIdH.IsKey(OutNId)) { // not yet burned
          HasAliveNbrs = true;
          if (Rnd.GetUniDev() < FwdBurnProb) {
            BurnedNIdH.AddDat(OutNId);  NewBurnedNIdV.Add(OutNId);  NBurned++; }
        }
      }
      // burn backward links (in-links)
      if (BckBurnProb > 0.0) {
        for (int e = 0; e < Node.GetInDeg(); e++) {
          const int InNId = Node.GetInNId(e);
          if (! BurnedNIdH.IsKey(InNId)) { // not yet burned
            HasAliveNbrs = true;
            if (Rnd.GetUniDev() < BckBurnProb) {
              BurnedNIdH.AddDat(InNId);  NewBurnedNIdV.Add(InNId);  NBurned++; }
          }
        }
      }
      if (! HasAliveNbrs) { NDiedFire++; }
    }
    NBurnedTmV.Add(NBurned);
    NBurningTmV.Add(BurningNIdV.Len() - NDiedFire);
    NewBurnedTmV.Add(NewBurnedNIdV.Len());
    //BurningNIdV.AddV(NewBurnedNIdV);   // node is burning eternally
    BurningNIdV.Swap(NewBurnedNIdV);    // node is burning just 1 time step
    if (BurningNIdV.Empty()) break;
    FwdBurnProb = FwdBurnProb * ProbDecay;
    BckBurnProb = BckBurnProb * ProbDecay;
  }
  BurnedNIdV.Gen(BurnedNIdH.Len(), 0);
  for (int i = 0; i < BurnedNIdH.Len(); i++) {
    BurnedNIdV.Add(BurnedNIdH.GetKey(i)); }
  FwdBurnProb = OldFwdBurnProb;
  BckBurnProb = OldBckBurnProb;
}
开发者ID:hdravna,项目名称:CommDet,代码行数:59,代码来源:ff.cpp

示例6: GetCatIdV

/////////////////////////////////////////////////
// DMoz-Base
void TDMozBs::GetCatIdV(const TStrV& CatNmV, TIntV& CatIdV) const {
  CatIdV.Clr();
  for (int CatNmN=0; CatNmN<CatNmV.Len(); CatNmN++){
    int CatId=GetCatId(CatNmV[CatNmN]);
    if (CatId==-1){
      printf("\nWarning: Invalid Category Name ('%s')\n.", CatNmV[CatNmN].CStr());}
    CatIdV.Add(CatId);
  }
}
开发者ID:jethrotan,项目名称:qminer,代码行数:11,代码来源:dmoz.cpp

示例7: GetAddWIdV

// and words to StrH and get a vector of word ids
void TStrUtil::GetAddWIdV(TStrHash<TInt>& StrH, const char *CStr, TIntV& WIdV) {
  TChA ChA(CStr);
  TVec<char *> WrdV;
  TInt WId;
  TStrUtil::SplitWords(ChA, WrdV);
  WIdV.Clr(false);
  for (int w = 0; w < WrdV.Len(); w++) {
    WIdV.Add(StrH.AddDatId(WrdV[w]));
  }
}
开发者ID:hmipakchi,项目名称:FinalYearProject,代码行数:11,代码来源:util.cpp

示例8: CmtyGirvanNewmanStep

// GIRVAN-NEWMAN algorithm
//	1. The betweenness of all existing edges in the network is calculated first.
//	2. The edge with the highest betweenness is removed.
//	3. The betweenness of all edges affected by the removal is recalculated.
//	4. Steps 2 and 3 are repeated until no edges remain.
//  Girvan M. and Newman M. E. J., Community structure in social and biological networks, Proc. Natl. Acad. Sci. USA 99, 7821–7826 (2002)
// Keep removing edges from Graph until one of the connected components of Graph splits into two.
void CmtyGirvanNewmanStep(PUNGraph& Graph, TIntV& Cmty1, TIntV& Cmty2) {
  TIntPrFltH BtwEH;
  TBreathFS<PUNGraph> BFS(Graph);
  Cmty1.Clr(false);  Cmty2.Clr(false);
  while (true) {
    TSnap::GetBetweennessCentr(Graph, BtwEH);
    BtwEH.SortByDat(false);
    if (BtwEH.Empty()) { return; }
    const int NId1 = BtwEH.GetKey(0).Val1;
    const int NId2 = BtwEH.GetKey(0).Val2;
    Graph->DelEdge(NId1, NId2);
    BFS.DoBfs(NId1, true, false, NId2, TInt::Mx);
    if (BFS.GetHops(NId1, NId2) == -1) { // two components
      TSnap::GetNodeWcc(Graph, NId1, Cmty1);
      TSnap::GetNodeWcc(Graph, NId2, Cmty2);
      return;
    }
  }
}
开发者ID:pikma,项目名称:Snap,代码行数:26,代码来源:cmty.cpp

示例9: MakeExpBins

void TGUtil::MakeExpBins(const TIntV& YValV, TIntV& ExpYValV, const double& BinFactor) {
  ExpYValV.Clr(true);
  int prevI=0;
  for (int i = 0; i < YValV.Len(); ) {
    ExpYValV.Add(YValV[i]);
    i = int(i*BinFactor);
    if (i==prevI) { i++; }
    prevI = i;
  }
}
开发者ID:hmipakchi,项目名称:FinalYearProject,代码行数:10,代码来源:util.cpp

示例10: GetDstSynSetPV

/////////////////////////////////////////////////
// WordNet-SynSet
void TWnSynSet::GetDstSynSetPV(
 const TWnRelType& RelType, TIntV& DstSynSetPV) const {
  DstSynSetPV.Clr();
  for (int RelN=0; RelN<RelIntIntTrV.Len(); RelN++){
    TWnRelType CurRelType=TWnRelType(RelIntIntTrV[RelN].Val1.Val);
    if (RelType==CurRelType){
      int DstSynSetP=RelIntIntTrV[RelN].Val3;
      DstSynSetPV.Add(DstSynSetP);
    }
  }
}
开发者ID:AlertProject,项目名称:Text-processing-bundle,代码行数:13,代码来源:wordnet.cpp

示例11: GetWIdV

void TStrUtil::GetWIdV(const TStrHash<TInt>& StrH, const char *CStr, TIntV& WIdV) {
  const int NotWId = -1;
  TChA ChA(CStr);
  TVec<char *> WrdV;
  TInt WId;
  TStrUtil::SplitWords(ChA, WrdV);
  WIdV.Clr(false);
  for (int w = 0; w < WrdV.Len(); w++) {
    if (StrH.IsKeyGetDat(WrdV[w], WId)) { WIdV.Add(WId); }
    else { WIdV.Add(NotWId); }
  }
}
开发者ID:hmipakchi,项目名称:FinalYearProject,代码行数:12,代码来源:util.cpp

示例12: JoinItems

void TTrawling::JoinItems(const TIntV& Item1, const TIntV& Item2, TIntV& JoinItem) {
  int i = 0, j = 0;
  JoinItem.Clr(false);
  const int MaxL = Item1.Len()+1;
  while (i < Item1.Len()) {
    while (j < Item2.Len() && Item2[j] < Item1[i]) {
      JoinItem.Add(Item2[j]); j++; }
    JoinItem.Add(Item1[i]);
    if (j < Item2.Len() && Item1[i] == Item2[j]) { j++; }
    i++;
    if (JoinItem.Len() > MaxL) { JoinItem.Clr(false); return; }
  }
  while (j < Item2.Len()) {
    JoinItem.Add(Item2[j]); j++;
  }
  /*if (JoinItem.Len() > 3) {
    Dump(Item1, "\n1:");
    Dump(Item2, "2:");
    Dump(JoinItem, "J:");
  }*/
  IAssert(JoinItem.IsSorted());
}
开发者ID:Aleyasen,项目名称:Alaki,代码行数:22,代码来源:trawling.cpp

示例13: Parse

void TEvalScore::Parse(const TStr& Str, TIntV& WIdV) {
    TStrV TokenV; Tokenize(Str, TokenV); WIdV.Clr();
    for (int WdN = 0; WdN < TokenV.Len(); WdN++) {
        // get the word string
        TStr WdStr = TokenV[WdN];
        // get id of the word
        int WId = WordH.GetKeyId(WdStr);
        // word does not exist yet, add it to the hash table
        if (WId == -1) { WId = WordH.AddKey(WdStr); }
        // add word to the parsed sentence
        WIdV.Add(WId);
    }
}
开发者ID:AlertProject,项目名称:Text-processing-bundle,代码行数:13,代码来源:biling.cpp

示例14: grafoJSON

void grafoJSON(PUNGraph G) {
  
  std::ofstream myfile;
  std::vector<int> nodos = obtenerVerticesOrdenados(G);
  TIntV conexiones;
  
  myfile.open("facebook.json");
  
  
  myfile << "{ \"graph\": {" << "\n";
  myfile << "\"nodes\": [" << "\n";
  
  for (int i = 0; i < nodos.size(); i++) {
    myfile << "{ \"id\": \"" << nodos[i] << "\" }";
    if (i == nodos.size()-1) {
      myfile << " ]," << "\n";
    }
    else {
      myfile << "," << "\n";
    }
  }
  
  myfile << "\"edges\": [\n";
  
  for (int i = 0; i < nodos.size(); i++) {
    
    GetNodesAtHop(G, nodos[i], 1, conexiones, false);
    
    for (int j = 0; j < conexiones.EndI() - conexiones.BegI(); j++) {
      if (conexiones[j] > i) {
        myfile << "{ \"source\": \"" << i << "\", \"target\": \"" << conexiones[j] << "\" }";
        if (i == nodos.size()-1) {
          myfile << " ]" << "\n";
        }
        else {
          myfile << "," << "\n";
        }
      }
    }
    
    conexiones.Clr();
    
  }
  
  myfile << "} }";
  
  myfile.close();
  
  
}
开发者ID:yocoHM,项目名称:grafosGephi,代码行数:50,代码来源:main.cpp

示例15: GenBlockLenV

void TBlobBs::GenBlockLenV(TIntV& BlockLenV){
  BlockLenV.Clr();
  for (int P2Exp=0; P2Exp<TB4Def::MxP2Exp; P2Exp++){
    BlockLenV.Add(TInt(TB4Def::GetP2(P2Exp)));}
  EAssert(int(BlockLenV.Last())<2000000000);

  {for (int Len=10; Len<100; Len+=10){BlockLenV.Add(Len);}}
  {for (int Len=100; Len<10000; Len+=100){BlockLenV.Add(Len);}}
  {for (int Len=10000; Len<100000; Len+=1000){BlockLenV.Add(Len);}}
  {for (int Len=100000; Len<1000000; Len+=25000){BlockLenV.Add(Len);}}
  {for (int Len=1000000; Len<10000000; Len+=1000000){BlockLenV.Add(Len);}}
  {for (int Len=10000000; Len<100000000; Len+=10000000){BlockLenV.Add(Len);}}

  BlockLenV.Sort();
}
开发者ID:adobekan,项目名称:qminer,代码行数:15,代码来源:blobbs.cpp


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