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


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

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


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

示例1: AttrId

TEST(TNEANet, GetSAttrDatE_str) {
  PNEANet Graph;
  Graph = TNEANet::New();
  Graph->AddNode(0);
  Graph->AddNode(1);
  Graph->AddEdge(0, 1, 0);
  TStr Val;
  TInt AttrId(0);
  TStr AttrName("TestInt");
  TInt EId(0);
  int status = Graph->GetSAttrDatE(EId, AttrName, Val);
  EXPECT_EQ(-1, status);
  status = Graph->GetSAttrDatE(EId, AttrId, Val);
  EXPECT_EQ(-1, status);
  Graph->AddSAttrE(AttrName, atStr, AttrId);
  TStr TestVal("5");
  Graph->AddSAttrDatE(EId, AttrId, TestVal);
  status = Graph->GetSAttrDatE(EId, AttrId, Val);
  EXPECT_EQ(0, status);
  EXPECT_STREQ(TestVal.CStr(), Val.CStr());
  status = Graph->GetSAttrDatE(EId, AttrName, Val);
  EXPECT_EQ(0, status);
  EXPECT_STREQ(TestVal.CStr(), Val.CStr());
  TInt ErrorId(1);
  status = Graph->GetSAttrDatE(ErrorId, AttrId, Val);
  EXPECT_EQ(-1, status);
}
开发者ID:IsmaelAli,项目名称:snap,代码行数:27,代码来源:test-TNEANet.cpp

示例2: IntAttr

TEST(TNEANet, GetIdVSAttrE) {
  PNEANet Graph;
  Graph = TNEANet::New();
  TStr IntAttr("TestInt");
  TInt IntId;
  Graph->AddSAttrE(IntAttr, atInt, IntId);
  TStr FltAttr("TestFlt");
  TInt FltId;
  Graph->AddSAttrE(FltAttr, atFlt, FltId);
  TStr StrAttr("TestStr");
  TInt StrId;
  Graph->AddSAttrE(StrAttr, atStr, StrId);

  TInt IntVal(0);
  TFlt FltVal(0);
  TStr StrVal("test");
  Graph->AddNode(0);
  for (int i = 0; i < 10; i++) {
    Graph->AddNode(i+1);
    Graph->AddEdge(i, i+1, i);
    TInt Id(i);
    Graph->AddSAttrDatE(Id, IntId, IntVal);
    if (i%2 == 0) {
      Graph->AddSAttrDatE(Id, FltId, FltVal);
    }
  }
  Graph->AddSAttrDatE(0, StrId, StrVal);

  TIntV IdV;
  Graph->GetIdVSAttrE(IntAttr, IdV);
  EXPECT_EQ(10, IdV.Len());
  Graph->GetIdVSAttrE(IntId, IdV);
  EXPECT_EQ(10, IdV.Len());

  Graph->GetIdVSAttrE(FltAttr, IdV);
  EXPECT_EQ(5, IdV.Len());
  Graph->GetIdVSAttrE(FltId, IdV);
  EXPECT_EQ(5, IdV.Len());

  Graph->GetIdVSAttrE(StrAttr, IdV);
  EXPECT_EQ(1, IdV.Len());
  Graph->GetIdVSAttrE(StrId, IdV);
  EXPECT_EQ(1, IdV.Len());
}
开发者ID:IsmaelAli,项目名称:snap,代码行数:44,代码来源:test-TNEANet.cpp

示例3: Val

TEST(TNEANet, AddSAttrDatE_flt) {
  PNEANet Graph;
  Graph = TNEANet::New();
  Graph->AddNode(0);
  Graph->AddNode(1);
  Graph->AddEdge(0, 1, 0);
  TFlt Val(5.0);
  TInt Id(0);
  int status = Graph->AddSAttrDatE(Id, 1, Val);
  EXPECT_EQ(-1, status);
  TInt AttrId;
  TStr AttrName("TestFlt");
  Graph->AddSAttrE(AttrName, atFlt, AttrId);
  TInt ErrorVal(1);
  status = Graph->AddSAttrDatE(Id, AttrId, ErrorVal);
  EXPECT_EQ(-2, status);
  status = Graph->AddSAttrDatE(Id, AttrId, Val);
  EXPECT_EQ(0, status);
  status = Graph->AddSAttrDatE(Id, AttrName, Val);
  EXPECT_EQ(0, status);
  TStr NewName("TestFlt2");
  status = Graph->AddSAttrDatE(Id, NewName, Val);
  EXPECT_EQ(0, status);
  TInt ErrorId(1);
  status = Graph->AddSAttrDatE(ErrorId, AttrId, Val);
  EXPECT_EQ(-1, status);
}
开发者ID:IsmaelAli,项目名称:snap,代码行数:27,代码来源:test-TNEANet.cpp


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