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


C++ TNodeI::GetOutNId方法代码示例

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


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

示例1: ReinforceEdges

// IN-OUT edges are swapped (so that the prog runs faster)
// Send message via IN edge proportional to the OUT edge weight
void TWgtNet::ReinforceEdges(const int& NIters) {
  THash<TInt, TFlt> OutWgtSumH;
  for (TNodeI NI = BegNI(); NI < EndNI(); NI++) {
    double wgt = 0;
    for (int e = 0; e < NI.GetOutDeg(); e++) { 
      wgt += NI.GetOutEDat(e); }
    OutWgtSumH.AddDat(NI.GetId(), wgt);
  }
  printf("Reinforcing edges for %d iterations\n", NIters);
  // iterate
  TExeTm ExeTm;
  for (int iter = 0; iter < NIters; iter++) {
    for (TNodeI NI = BegNI(); NI < EndNI(); NI++) {
      const double X = TInt::Rnd.GetUniDev() * OutWgtSumH.GetDat(NI.GetId());
      double x = 0;  int e = 0;
      for ( ; x + NI.GetOutEDat(e) < X; e++) {
        x += NI.GetOutEDat(e); }
      IAssert(IsEdge(NI.GetOutNId(e), NI.GetId()));
      GetEDat(NI.GetOutNId(e), NI.GetId()) += 1; // reinforce the edge
      OutWgtSumH.GetDat(NI.GetOutNId(e)) += 1; 
    }
    if (iter % (NIters/100) == 0) {
      printf("\r%d [%s]", iter, ExeTm.GetStr()); 
    }
  }
  printf(" done.\n");
}
开发者ID:Aleyasen,项目名称:Alaki,代码行数:29,代码来源:wgtnet.cpp

示例2: AddBiDirEdges

// Wgt == -1 : take the weight of the edge in the opposite direction
void TWgtNet::AddBiDirEdges(const double& Wgt) {
  TIntPrV EdgeV;
  for (TNodeI NI = BegNI(); NI < EndNI(); NI++) {
    for (int e = 0; e < NI.GetOutDeg(); e++) { 
      if (! IsEdge(NI.GetOutNId(e), NI.GetId())) {
        EdgeV.Add(TIntPr(NI.GetOutNId(e), NI.GetId())); }
    }
  }
  for (int e = 0; e < EdgeV.Len(); e++) {
    if (Wgt != -1) {
      AddEdge(EdgeV[e].Val1, EdgeV[e].Val2, Wgt);
    } else { // edge weight in the opposite direction
      AddEdge(EdgeV[e].Val1, EdgeV[e].Val2, GetEDat(EdgeV[e].Val2, EdgeV[e].Val1));
    }
  }
}
开发者ID:Aleyasen,项目名称:Alaki,代码行数:17,代码来源:wgtnet.cpp

示例3: GetActorGraph

// 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

示例4: 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

示例5: RandomWalk

void TMultimodalGraphImplB::RandomWalk(TVec< TPair<TInt,TInt> > NodeIds, int WalkLength) {
  int CurrentLocalNodeId = NodeToModeMapping.GetKey(NodeToModeMapping.GetRndKeyId(TInt::Rnd));
  TPair<TInt,TInt> CurrentNodeId = TPair<TInt,TInt>(NodeToModeMapping.GetDat(CurrentLocalNodeId), CurrentLocalNodeId);
  int NodeIdIdx = 0;
  NodeIds.SetVal(NodeIdIdx++, CurrentNodeId);
  while (NodeIds.Len() < WalkLength) {
    TNodeI NI = GetNI(CurrentNodeId);
    TIntV AdjacentModes = TIntV(); NI.GetAdjacentModes(AdjacentModes);
    // Throw an appropriately biased coin here
    int EdgeId = TInt::Rnd.GetUniDevInt(NI.GetOutDeg());
    int i;
    for (i = 0; i < AdjacentModes.Len(); i++) {
      int ModeOutDeg = NI.GetOutDeg(AdjacentModes.GetDat(i));
      if (EdgeId < ModeOutDeg) { break; }
      EdgeId -= ModeOutDeg;
    }
    NodeIds.SetVal(NodeIdIdx++, TPair<TInt,TInt>(AdjacentModes.GetDat(i), NI.GetOutNId(EdgeId, AdjacentModes.GetDat(i))));
  }
}
开发者ID:deepakn94,项目名称:snap-dev,代码行数:19,代码来源:multimodalGraphImplB.cpp


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