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


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

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


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

示例1: GetSubGraph

TIntNNet TMultimodalGraphImplB::GetSubGraph(const TIntV ModeIds) const {
  TIntNNet SubGraph = TIntNNet();

  for (THash<TInt,TInt>::TIter CurI = NodeToModeMapping.BegI(); CurI < NodeToModeMapping.EndI(); CurI++) {
    if (ModeIds.IsIn(CurI.GetDat())) {
      SubGraph.AddNode(CurI.GetKey(), CurI.GetDat());
    }
  }

  for (int ModeIdx1 = 0; ModeIdx1 < ModeIds.Len(); ModeIdx1++) {
    int ModeId1 = ModeIds.GetVal(ModeIdx1);
    for (int ModeIdx2 = 0; ModeIdx2 < ModeIds.Len(); ModeIdx2++) {
      int ModeId2 = ModeIds.GetVal(ModeIdx2);
      TPair<TInt,TInt> ModeIdsKey = GetModeIdsKey(ModeId1, ModeId2);
      if (!Graphs.IsKey(ModeIdsKey)) { continue; }
      const TNGraph& Graph = Graphs.GetDat(ModeIdsKey);
      for (TNGraph::TNodeI it = Graph.BegNI(); it < Graph.EndNI(); it++) {
        for (int e = 0; e < it.GetOutDeg(); e++) {
          SubGraph.AddEdge(it.GetId(), it.GetOutNId(e));
        }
      }
    }
  }
  printf("Number of nodes in SubGraph: %d...\n", SubGraph.GetNodes());
  printf("Number of edges in SubGraph: %d...\n", SubGraph.GetEdges());

  return SubGraph;
}
开发者ID:deepakn94,项目名称:snap-dev,代码行数:28,代码来源:multimodalGraphImplB.cpp

示例2: GetSubGraphMocked

int TMultimodalGraphImplB::GetSubGraphMocked(const TIntV ModeIds) const {
  int NumVerticesAndEdges = 0;

  for (THash<TInt,TInt>::TIter CurI = NodeToModeMapping.BegI(); CurI < NodeToModeMapping.EndI(); CurI++) {
    if (ModeIds.IsIn(CurI.GetDat())) {
      NumVerticesAndEdges++;
    }
  }

  for (int ModeIdx1 = 0; ModeIdx1 < ModeIds.Len(); ModeIdx1++) {
    int ModeId1 = ModeIds.GetVal(ModeIdx1);
    for (int ModeIdx2 = 0; ModeIdx2 < ModeIds.Len(); ModeIdx2++) {
      int ModeId2 = ModeIds.GetVal(ModeIdx2);
      TPair<TInt,TInt> ModeIdsKey = GetModeIdsKey(ModeId1, ModeId2);
      if (!Graphs.IsKey(ModeIdsKey)) { continue; }
      const TNGraph& Graph = Graphs.GetDat(ModeIdsKey);
      for (TNGraph::TNodeI it = Graph.BegNI(); it < Graph.EndNI(); it++) {
        for (int e = 0; e < it.GetOutDeg(); e++) {
          NumVerticesAndEdges += it.GetOutNId(e);
        }
      }
    }
  }

  return NumVerticesAndEdges;
}
开发者ID:deepakn94,项目名称:snap-dev,代码行数:26,代码来源:multimodalGraphImplB.cpp

示例3: BFSTraversalOneHop

int TMultimodalGraphImplB::BFSTraversalOneHop(const TVec< TPair<TInt,TInt> >& StartingVertices) const {
  int NumVerticesAndEdges = 0;
  for (int i = 0; i < StartingVertices.Len(); i++) {
    TNodeI NI = GetNI(StartingVertices.GetVal(i));
    TIntV AdjacentModes = TIntV(); NI.GetAdjacentModes(AdjacentModes);
    for (int ModeIdx = 0; ModeIdx < AdjacentModes.Len(); ModeIdx++) {
      int ModeId = AdjacentModes.GetVal(ModeIdx);
      for (int e = 0; e < NI.GetOutDeg(ModeId); e++) {
        NumVerticesAndEdges += NI.GetOutNId(e, ModeId);
      }
    }
  }
  return NumVerticesAndEdges;
}
开发者ID:deepakn94,项目名称:snap-dev,代码行数:14,代码来源:multimodalGraphImplB.cpp

示例4: main

/**
 * Used for benchmarking sorting by source algorithm.
 * Takes as input starting point of
 * a top cascade and outputs time taken for casacade detection. 
 * Input : Source, Dest, Start, Duration 
 * Output : Prints the time for cascade detection
 */
int main(int argc,char* argv[]) {
  TTableContext Context;
  Schema TimeS;
  TimeS.Add(TPair<TStr,TAttrType>("Source",atInt));
  TimeS.Add(TPair<TStr,TAttrType>("Dest",atInt));
  TimeS.Add(TPair<TStr,TAttrType>("Start",atInt));
  TimeS.Add(TPair<TStr,TAttrType>("Duration",atInt));
  PTable P1 = TTable::LoadSS(TimeS,"./../../../../datasets/temporal/yemen_call_201001.txt",&Context,' ');
  TIntV MapV;
  TStrV SortBy;
  SortBy.Add("Source");
  P1->Order(SortBy);
  TIntV Source; // Sorted vec of start time
  P1->ReadIntCol("Source",Source);
  for (TRowIterator RI = P1->BegRI(); RI < P1->EndRI(); RI++) {
    MapV.Add(RI.GetRowIdx());
  }
  // Attribute to Int mapping
  TInt SIdx = P1->GetColIdx("Source");
  TInt DIdx = P1->GetColIdx("Dest");
  TInt StIdx = P1->GetColIdx("Start");
  TInt DuIdx = P1->GetColIdx("Duration");
  int W = atoi(argv[1]);
  int len = 0;
  // Find the starting point
  int TSource = atoi(argv[2]);
  int TDest = atoi(argv[3]);
  int TStart = atoi(argv[4]);
  int TDur = atoi(argv[5]);
  TInt RIdx;
  for (TRowIterator RI = P1->BegRI(); RI < P1->EndRI(); RI++) {
    RIdx = RI.GetRowIdx();
    int RSource = P1->GetIntValAtRowIdx(SIdx,RIdx).Val;
    int RDest = P1->GetIntValAtRowIdx(DIdx,RIdx).Val;
    int RStart = P1->GetIntValAtRowIdx(StIdx,RIdx).Val;
    int RDur = P1->GetIntValAtRowIdx(DuIdx,RIdx).Val;
    if (TSource == RSource && TDest == RDest && TStart == RStart && TDur == RDur) break;
  }
  // Start building the cascade from the start point
  clock_t st,et;
  st = clock();
  for (int i = 0; i < 1; i++) {
    THashSet<TInt> VisitedH;
    TSnapQueue<TInt> EventQ;
    EventQ.Push(RIdx);
    VisitedH.AddKey(RIdx);
    while (!EventQ.Empty()) {
      TInt CIdx = EventQ.Top();
      EventQ.Pop();
      int CDest = P1->GetIntValAtRowIdx(DIdx,CIdx).Val;
      int CStart = P1->GetIntValAtRowIdx(StIdx,CIdx).Val;
      int CDur = P1->GetIntValAtRowIdx(DuIdx,CIdx).Val;
      // In line binary search
      int val = CDest;
      int lo = 0;
      int hi = Source.Len() - 1;
      int index = -1;
      while (hi >= lo) {
        int mid = lo + (hi - lo)/2;
        if (Source.GetVal(mid) > val) { hi = mid - 1;}
        else if (Source.GetVal(mid) < val) { lo = mid + 1;}
        else { index = mid; hi = mid - 1;}
      } 
      // End of binary search
      int BIdx = index;
      for(int i = BIdx; i < Source.Len(); i++) {
        int PId = MapV.GetVal(i).Val;
        if (! VisitedH.IsKey(PId)) {
          int TSource = P1->GetIntValAtRowIdx(SIdx,PId).Val;
          int TStart = P1->GetIntValAtRowIdx(StIdx,PId).Val;
          if (TSource != CDest) {
            break;
          }
          if (TStart >= (CDur + CStart) && TStart - (CDur + CStart) <= W) {
            VisitedH.AddKey(PId);
            EventQ.Push(PId);
          }
        }
      }
    }
    len = VisitedH.Len();
  }
  et = clock();
  float diff = ((float) et - (float) st)/CLOCKS_PER_SEC;
  printf("Size %d,Time %f\n",len,diff);
  return 0;
}
开发者ID:JohnMatta,项目名称:snap,代码行数:94,代码来源:sortSource.cpp


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