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


C++ PNEANet::GetIntAttrDatE方法代码示例

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


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

示例1: StrAttr

TEST(TNEANet, AddEdgeAttributeError) {
  PNEANet Graph;
  Graph = TNEANet::New();

  TStr StrAttr("name");
  TStr FltAttr("weight");
  TStr IntAttr("test");

  Graph->AddStrAttrE(StrAttr);
  Graph->AddFltAttrE(FltAttr);
  Graph->AddIntAttrE(IntAttr);
  int NumEdges = 5;
  for (int i = 0; i < NumEdges + 1; i++) {
    Graph->AddNode(i);
  }
  for (int i = 0; i < NumEdges; i++) {
    Graph->AddEdge(i, i+1, i);
    Graph->AddIntAttrDatE(i, TInt(i), IntAttr);
    Graph->AddFltAttrDatE(i, TFlt(i), FltAttr);
    TInt Val(i);
    Graph->AddStrAttrDatE(i, Val.GetStr(), StrAttr);
  }
  Graph->DelNode(0);
  for (int j = 1; j < NumEdges; j++) {
    ASSERT_EQ(Graph->GetIntAttrDatE(j, IntAttr), TInt(j));
    ASSERT_EQ(Graph->GetFltAttrDatE(j, FltAttr), TFlt(j));
    TInt Val(j);
    ASSERT_EQ(Graph->GetStrAttrDatE(j, StrAttr), Val.GetStr());
  }
}
开发者ID:IsmaelAli,项目名称:snap,代码行数:30,代码来源:test-TNEANet.cpp

示例2: FOut


//.........这里部分代码省略.........
  Graph->AddStrAttrDatE(455, "", attr1);

  EXPECT_EQ('c', Graph->GetEAStrI(attr1, 10).GetDat().LastCh());
  EXPECT_EQ('f', Graph->GetEAStrI(attr1, 20).GetDat().LastCh());

  EdgeId = 0;
  DefEdges = 0;
  TAStrIV.Clr();

  for (TNEANet::TAStrI EI = Graph->BegEAStrI(attr1);
    EI < Graph->EndEAStrI(attr1); EI++) {
    if (EI.GetDat() != TStr::GetNullStr()) {
      TAStrIV.Add(EI.GetDat());
      EdgeId++;
    } else {
      DefEdges++;
    }
  } 

  EXPECT_EQ(3, EdgeId);
  EXPECT_EQ(NEdges - 3, DefEdges);
  TAStrIV.Sort();
  // TODO(nkhadke): Fix hack to compare strings properly. This works for now.
  EXPECT_EQ('c', TAStrIV[0].LastCh());
  EXPECT_EQ('f', TAStrIV[1].LastCh());
  EXPECT_EQ('i', TAStrIV[2].LastCh());

  // Test vertical iterator over many types (must skip default/deleted attr) 
  int EId = 55;
  Graph->AddStrAttrDatE(EId, "aaa", attr1);
  Graph->AddIntAttrDatE(EId, 3*2, attr2);
  Graph->AddFltAttrDatE(EId, 3.41, attr3);
  Graph->AddStrAttrDatE(80, "dont appear", attr4); // should not show up  

  TStrV EIdAttrName;
  Graph->AttrNameEI(EId, EIdAttrName);
  AttrLen = EIdAttrName.Len();
  EXPECT_EQ(3, AttrLen);
  
  Graph->DelAttrDatE(EId, attr2);
  Graph->AttrNameEI(EId, EIdAttrName);
  AttrLen = EIdAttrName.Len();
  for (i = 0; i < AttrLen; i++) {
    if (TStr("int") == EIdAttrName[i]()) {
      // FAIL
      EXPECT_EQ(2,3);
    }
  }

  Graph->AddIntAttrDatE(EId, 3*2, attr2);
  Graph->DelAttrE(attr1);
  Graph->AttrNameEI(EId, EIdAttrName);
  AttrLen = EIdAttrName.Len();
  for (i = 0; i < AttrLen; i++) {
    if (TStr("aaa") == EIdAttrName[i]()) {
      // FAIL
      EXPECT_EQ(2,3);
    }
  }

  TStrV EIdAttrValue;
  Graph->AttrValueEI(EId, EIdAttrValue);
  AttrLen = EIdAttrValue.Len();
  for (i = 0; i < AttrLen; i++) {
    if (TStr("str") == EIdAttrValue[i]()) {
      // FAIL
      EXPECT_EQ(2,3);
    }
  }

  expectedTotal = 0;
  for (i = 0; i <NEdges; i++) {
    Graph->AddIntAttrDatE(i, NEdges+i, attr2);
    EXPECT_EQ(NEdges+i, Graph->GetIntAttrDatE(i, attr2));
    expectedTotal += NEdges+i;
  }

  {
    TFOut FOut(FName);
    Graph->Save(FOut);
    FOut.Flush();
    Graph->Clr();
  }

  {
    TFIn FIn(FName);
    Graph1 = TNEANet::Load(FIn);
  }

  total = 0;
  for (TNEANet::TAIntI EI = Graph1->BegNAIntI(attr2);
    EI < Graph1->EndNAIntI(attr2); EI++) {
    total += EI.GetDat();
  }

  EXPECT_EQ(expectedTotal, total);

  //Graph1->Dump();
  Graph1->Clr();
}
开发者ID:IsmaelAli,项目名称:snap,代码行数:101,代码来源:test-TNEANet.cpp


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