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()); } }
void node2vec(PNEANet& InNet, double& ParamP, double& ParamQ, int& Dimensions, int& WalkLen, int& NumWalks, int& WinSize, int& Iter, bool& Verbose, TIntFltVH& EmbeddingsHV) { PWNet NewNet = PWNet::New(); for (TNEANet::TEdgeI EI = InNet->BegEI(); EI < InNet->EndEI(); EI++) { if (!NewNet->IsNode(EI.GetSrcNId())) { NewNet->AddNode(EI.GetSrcNId()); } if (!NewNet->IsNode(EI.GetDstNId())) { NewNet->AddNode(EI.GetDstNId()); } NewNet->AddEdge(EI.GetSrcNId(), EI.GetDstNId(), InNet->GetFltAttrDatE(EI,"weight")); } node2vec(NewNet, ParamP, ParamQ, Dimensions, WalkLen, NumWalks, WinSize, Iter, Verbose, EmbeddingsHV); }