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()); } }
// Test node, edge attribute functionality TEST(TNEANet, AddEdgeNodeAfterAttrAdded) { PNEANet Graph; Graph = TNEANet::New(); TStr StrAttr("name"); TStr EIntAttr("weight"); TStr NIntAttr("test"); Graph->AddStrAttrN(StrAttr); Graph->AddIntAttrN(NIntAttr); Graph->AddIntAttrE(EIntAttr); Graph->AddNode(0); Graph->AddNode(1); Graph->AddNode(2); Graph->AddStrAttrDatN(0, "zero", StrAttr); Graph->AddStrAttrDatN(1, "one", StrAttr); Graph->AddStrAttrDatN(2, "two", StrAttr); Graph->AddEdge(0, 1); Graph->AddEdge(1, 2); Graph->AddEdge(2, 0); for (TNEANet::TEdgeI EI = Graph->BegEI(); EI < Graph->EndEI(); EI++) { Graph->AddIntAttrDatE(EI.GetId(), EI.GetId()*3+1, EIntAttr); } for (TNEANet::TEdgeI EI = Graph->BegEI(); EI < Graph->EndEI(); EI++) { TInt AttrVal = Graph->GetIntAttrDatE(EI.GetId(), EIntAttr); ASSERT_EQ(EI.GetId()*3+1, AttrVal); } }