void MakeSignEpinions() { TSsParser Ss("/u/ana/data/EpinionRatings/user_rating.txt", ssfTabSep); //PSignNet Net = TSignNet::New(); TPt<TNodeEDatNet<TInt, TInt> > Net = TNodeEDatNet<TInt, TInt>::New(); TStrHash<TInt> StrSet(Mega(1), true); while (Ss.Next()) { if ( ((TStr)Ss[0]).IsPrefix("#") ) continue; const int SrcNId = StrSet.AddKey(Ss[0]); const int DstNId = StrSet.AddKey(Ss[1]); if (! Net->IsNode(SrcNId)) { Net->AddNode(SrcNId); } if (! Net->IsNode(DstNId)) { Net->AddNode(DstNId); } const int Sign = ((TStr)Ss[2]).GetInt(); Net->AddEdge(SrcNId, DstNId, Sign); } // PrintGraphStatTable(Graph, OutFNm, Desc); TStr OutFNm = "soc-sign-epinions-user-ratings"; TStr Desc = "Epinions signed social network"; // copied from gio.h - line 111 FILE *F = fopen(OutFNm.CStr(), "wt"); fprintf(F, "# Directed graph: %s\n", OutFNm.CStr()); if (! Desc.Empty()) fprintf(F, "# %s\n", (Desc).CStr()); fprintf(F, "# Nodes: %d Edges: %d\n", Net->GetNodes(), Net->GetEdges()); fprintf(F, "# FromNodeId\tToNodeId\tSign\n"); for (TNodeEDatNet<TInt,TInt>::TEdgeI ei = Net->BegEI(); ei < Net->EndEI(); ei++) { fprintf(F, "%d\t%d\t%d\n", ei.GetSrcNId(), ei.GetDstNId(), ei()()); } fclose(F); PrintGraphStatTable(Net, OutFNm, Desc); }
void TestGraphDAG(TPt<TNodeEDatNet<TFlt, TFlt>>& pGraph, std::vector<int> vSeedIDs, int numIterations) { cout << "Starting BP from nodeID {"; for(int sourceNode : vSeedIDs) cout << sourceNode << " "; cout << "}\nThe input graph has " << pGraph->GetNodes() << " nodes and " << pGraph->GetEdges() << " edges.\n"; // Start traversing the graph tbb::tick_count tic = tbb::tick_count::now(); for(int i = 0; i<numIterations; ++i) ParallelBPFromNodeDAG(pGraph, vSeedIDs); double dElapsedTime = (tbb::tick_count::now() - tic).seconds(); cout << "Time elapsed for parallel BP: " << dElapsedTime/numIterations << " seconds\n"; tic = tbb::tick_count::now(); for(int i = 0; i<numIterations; ++i) ParallelBPFromNodeDAG_LevelSynchronous(pGraph, vSeedIDs); dElapsedTime = (tbb::tick_count::now() - tic).seconds(); cout << "Time elapsed for parallel level synchronous BP: " << dElapsedTime/numIterations << " seconds\n"; tic = tbb::tick_count::now(); for(int i = 0; i<numIterations; ++i) PropagateFromNodeDAG(pGraph, vSeedIDs); dElapsedTime = (tbb::tick_count::now() - tic).seconds(); cout << "Time elapsed for serial BP: " << dElapsedTime/numIterations << " seconds\n"; std::vector<int> vResult; CalculateRankFromSource_BellmanFord(pGraph, vSeedIDs, vResult); tic = tbb::tick_count::now(); for(int i = 0; i<numIterations; ++i) ParallelBPFromNode_SingleNodeUpdate(pGraph, vResult, vSeedIDs); dElapsedTime = (tbb::tick_count::now() - tic).seconds(); cout << "Time elapsed for ParallelBPFromNode_SingleNodeUpdate: " << dElapsedTime/numIterations << " seconds\n"; }
// Test update node data TEST(TNodeEdgeNet, UpdateNodeData) { int NNodes = 10000; int NEdges = 100000; TPt <TNodeEdgeNet<TInt, TInt> > Net; TPt <TNodeEdgeNet<TInt, TInt> > Net1; TPt <TNodeEdgeNet<TInt, TInt> > Net2; int i; int n; int NCount; int x,y; Net = TNodeEdgeNet<TInt, TInt>::New(); EXPECT_EQ(1,Net->Empty()); // create the nodes for (i = 0; i < NNodes; i++) { Net->AddNode(i,i+5); } EXPECT_EQ(0,Net->Empty()); EXPECT_EQ(NNodes,Net->GetNodes()); // create random edges NCount = NEdges; while (NCount > 0) { x = (long) (drand48() * NNodes); y = (long) (drand48() * NNodes); n = Net->AddEdge(x, y); NCount--; } EXPECT_EQ(NEdges,Net->GetEdges()); EXPECT_EQ(0,Net->Empty()); EXPECT_EQ(1,Net->IsOk()); for (i = 0; i < NNodes; i++) { EXPECT_EQ(1,Net->IsNode(i)); } EXPECT_EQ(0,Net->IsNode(NNodes)); EXPECT_EQ(0,Net->IsNode(NNodes+1)); EXPECT_EQ(0,Net->IsNode(2*NNodes)); // test node data for (TNodeEdgeNet<TInt, TInt>::TNodeI NI = Net->BegNI(); NI < Net->EndNI(); NI++) { EXPECT_EQ(NI.GetId()+5, Net->GetNDat(NI.GetId())); } // update node data, node ID + 10 for (TNodeEdgeNet<TInt, TInt>::TNodeI NI = Net->BegNI(); NI < Net->EndNI(); NI++) { Net->SetNDat(NI.GetId(), NI.GetId()+10); } // test node data for (TNodeEdgeNet<TInt, TInt>::TNodeI NI = Net->BegNI(); NI < Net->EndNI(); NI++) { EXPECT_EQ(NI.GetId()+10, Net->GetNDat(NI.GetId())); } }
// Test the default constructor TEST(TNodeEdgeNet, DefaultConstructor) { TPt <TNodeEdgeNet<TInt, TInt> > Net; Net = TNodeEdgeNet<TInt, TInt>::New(); EXPECT_EQ(0,Net->GetNodes()); EXPECT_EQ(0,Net->GetEdges()); EXPECT_EQ(1,Net->IsOk()); EXPECT_EQ(1,Net->Empty()); EXPECT_EQ(1,Net->HasFlag(gfDirected)); EXPECT_EQ(1,Net->HasFlag(gfNodeDat)); }
void MakeSlashdotSignNet(const TStr InFNm, TStr OutFNm, TStr Desc, THashSet<TChA> NIdSet) { //THashSet<TChA> NIdSet; TChA LnStr; TVec<char *> WrdV; int Sign; //PSignNet Net = TSignNet::New(); TPt<TNodeEDatNet<TInt, TInt> > Net = TNodeEDatNet<TInt, TInt>::New(); int i = 0; for (TFIn FIn(InFNm); FIn.GetNextLn(LnStr); ) { if (LnStr.Empty() || LnStr[0]=='#') { continue; } LnStr.ToLc(); TStrUtil::SplitOnCh(LnStr, WrdV, '\t', false); //NIdSet.AddKey(WrdV[0]); if (strcmp(WrdV[1], "friends")==0) { Sign = 1; } else if (strcmp(WrdV[1], "fans")==0) { continue; } // skip (fans are in-friends) else if (strcmp(WrdV[1], "foes")==0) { Sign = -1; } else { Fail; } const int SrcNId = NIdSet.AddKey(WrdV[0]); if (! Net->IsNode(SrcNId)) { Net->AddNode(SrcNId); } for (int e = 2; e < WrdV.Len(); e++) { const int DstNId = NIdSet.AddKey(WrdV[e]); i ++ ; if ((SrcNId != DstNId) && ! Net->IsEdge(SrcNId, DstNId)) { if (! Net->IsNode(DstNId)) Net->AddNode(DstNId); Net->AddEdge(SrcNId, DstNId, Sign); } } } TSnap::PrintInfo(Net, "Slashdot (" + TInt::GetStr(i) + ")"); // copied from gio.h - line 111 FILE *F = fopen(OutFNm.CStr(), "wt"); fprintf(F, "# Directed graph: %s\n", OutFNm.CStr()); if (! Desc.Empty()) fprintf(F, "# %s\n", (Desc).CStr()); fprintf(F, "# Nodes: %d Edges: %d\n", Net->GetNodes(), Net->GetEdges()); fprintf(F, "# UserId\tGroupId\tSign\n"); for (TNodeEDatNet<TInt,TInt>::TEdgeI ei = Net->BegEI(); ei < Net->EndEI(); ei++) { fprintf(F, "%d\t%d\t%d\n", ei.GetSrcNId(), ei.GetDstNId(), ei()()); } fclose(F); PrintGraphStatTable(Net, OutFNm, Desc); }
// Test edge subgraphs TEST(subgraph, TestEdgeSubNets) { TPt <TNodeEdgeNet<TInt, TInt> > Net; TPt <TNodeEdgeNet<TInt, TInt> > Net1; TPt <TNodeEdgeNet<TInt, TInt> > Net2; TPt <TNodeEdgeNet<TInt, TInt> > Net3; TPt <TNodeEdgeNet<TInt, TInt> > Net4; int i; TIntV NIdV; TIntV NIdV1; Net = GetTestTNodeEdgeNet(); EXPECT_EQ(20,Net->GetNodes()); EXPECT_EQ(120,Net->GetEdges()); for (i = 10; i < 15; i++) { NIdV.Add(i); } Net1 = TSnap::GetSubGraph(Net, NIdV); EXPECT_EQ(5,Net1->GetNodes()); EXPECT_EQ(18,Net1->GetEdges()); for (i = 0; i < 20; i += 2) { NIdV1.Add(i); } Net2 = TSnap::GetSubGraph(Net, NIdV1); EXPECT_EQ(10,Net2->GetNodes()); EXPECT_EQ(20,Net2->GetEdges()); Net3 = TSnap::GetEDatSubGraph(Net, 1, 0); EXPECT_EQ(20,Net3->GetNodes()); EXPECT_EQ(30,Net3->GetEdges()); Net4 = TSnap::GetEDatSubGraph(Net, 2, -1); EXPECT_EQ(20,Net4->GetNodes()); EXPECT_EQ(60,Net4->GetEdges()); }
// Test edge data sorting TEST(TNodeEdgeNet, SortEdgeData) { int NNodes = 10000; int NEdges = 100000; TPt <TNodeEdgeNet<TInt, TInt> > Net; TPt <TNodeEdgeNet<TInt, TInt> > Net1; TPt <TNodeEdgeNet<TInt, TInt> > Net2; int i; int n; int x,y; bool Sorted; int Min; int Value; Net = TNodeEdgeNet<TInt, TInt>::New(); EXPECT_EQ(1,Net->Empty()); // create the nodes with node data x*x % NNodes for (i = 0; i < NNodes; i++) { x = (i*13) % NNodes; Net->AddNode(x, (x*x) % NNodes); } EXPECT_EQ(0,Net->Empty()); EXPECT_EQ(NNodes,Net->GetNodes()); // create random edges with edge data x*y % NEdges for (i = 0; i < NEdges; i++) { x = (long) (drand48() * NNodes); y = (long) (drand48() * NNodes); n = Net->AddEdge(x, y, (i*37) % NEdges, (x*y) % NEdges); } EXPECT_EQ(NEdges,Net->GetEdges()); EXPECT_EQ(0,Net->Empty()); EXPECT_EQ(1,Net->IsOk()); for (i = 0; i < NNodes; i++) { EXPECT_EQ(1,Net->IsNode(i)); } EXPECT_EQ(0,Net->IsNode(NNodes)); EXPECT_EQ(0,Net->IsNode(NNodes+1)); EXPECT_EQ(0,Net->IsNode(2*NNodes)); // test node data for (TNodeEdgeNet<TInt, TInt>::TNodeI NI = Net->BegNI(); NI < Net->EndNI(); NI++) { EXPECT_EQ((NI.GetId()*NI.GetId()) % NNodes, Net->GetNDat(NI.GetId())); } // test edge data for (TNodeEdgeNet<TInt, TInt>::TEdgeI EI = Net->BegEI(); EI < Net->EndEI(); EI++) { EXPECT_EQ((EI.GetSrcNId()*EI.GetDstNId()) % NEdges, Net->GetEDat(EI.GetId())); } // test sorting of edge IDs (unsorted) Min = -1; Sorted = true; for (TNodeEdgeNet<TInt, TInt>::TEdgeI EI = Net->BegEI(); EI < Net->EndEI(); EI++) { Value = EI.GetId(); if (Min > Value) { Sorted = false; } Min = Value; } EXPECT_EQ(false,Sorted); // sort the nodes by edge IDs (sorted) Net->SortEIdById(); // test sorting of edge IDs Min = -1; Sorted = true; for (TNodeEdgeNet<TInt, TInt>::TEdgeI EI = Net->BegEI(); EI < Net->EndEI(); EI++) { Value = EI.GetId(); if (Min > Value) { Sorted = false; } Min = Value; } EXPECT_EQ(true,Sorted); // test sorting of edge data (unsorted) Min = -1; Sorted = true; for (TNodeEdgeNet<TInt, TInt>::TEdgeI EI = Net->BegEI(); EI < Net->EndEI(); EI++) { Value = Net->GetEDat(EI.GetId()); if (Min > Value) { Sorted = false; } Min = Value; } EXPECT_EQ(false,Sorted); // sort the nodes by edge data Net->SortEIdByDat(); // test sorting of edge data (sorted) Min = -1; Sorted = true; for (TNodeEdgeNet<TInt, TInt>::TEdgeI EI = Net->BegEI(); EI < Net->EndEI(); EI++) { Value = Net->GetEDat(EI.GetId()); if (Min > Value) { Sorted = false; } Min = Value; } EXPECT_EQ(true,Sorted); // test sorting of edge IDs (unsorted) Min = -1; Sorted = true; for (TNodeEdgeNet<TInt, TInt>::TEdgeI EI = Net->BegEI(); EI < Net->EndEI(); EI++) { Value = EI.GetId(); if (Min > Value) { Sorted = false; } Min = Value; } EXPECT_EQ(false,Sorted); // test edge data for (TNodeEdgeNet<TInt, TInt>::TEdgeI EI = Net->BegEI(); EI < Net->EndEI(); EI++) { EXPECT_EQ((EI.GetSrcNId()*EI.GetDstNId()) % NEdges, Net->GetEDat(EI.GetId())); } // test node data for (TNodeEdgeNet<TInt, TInt>::TNodeI NI = Net->BegNI(); NI < Net->EndNI(); NI++) { EXPECT_EQ((NI.GetId()*NI.GetId()) % NNodes, Net->GetNDat(NI.GetId())); } }
// Test node data sorting TEST(TNodeEdgeNet, SortNodeData) { int NNodes = 10000; int NEdges = 100000; TPt <TNodeEdgeNet<TInt, TInt> > Net; TPt <TNodeEdgeNet<TInt, TInt> > Net1; TPt <TNodeEdgeNet<TInt, TInt> > Net2; int i; int n; int NCount; int x,y; bool Sorted; int Min; int Value; Net = TNodeEdgeNet<TInt, TInt>::New(); EXPECT_EQ(1,Net->Empty()); // create the nodes for (i = 0; i < NNodes; i++) { Net->AddNode((i*13) % NNodes); } EXPECT_EQ(0,Net->Empty()); EXPECT_EQ(NNodes,Net->GetNodes()); // create random edges NCount = NEdges; while (NCount > 0) { x = (long) (drand48() * NNodes); y = (long) (drand48() * NNodes); n = Net->AddEdge(x, y); NCount--; } EXPECT_EQ(NEdges,Net->GetEdges()); EXPECT_EQ(0,Net->Empty()); EXPECT_EQ(1,Net->IsOk()); for (i = 0; i < NNodes; i++) { EXPECT_EQ(1,Net->IsNode(i)); } EXPECT_EQ(0,Net->IsNode(NNodes)); EXPECT_EQ(0,Net->IsNode(NNodes+1)); EXPECT_EQ(0,Net->IsNode(2*NNodes)); // add data to nodes, square of node ID % NNodes for (TNodeEdgeNet<TInt, TInt>::TNodeI NI = Net->BegNI(); NI < Net->EndNI(); NI++) { // Net->AddNode(NI.GetId(), (NI.GetId()*NI.GetId()) % NNodes); Net->SetNDat(NI.GetId(), NI.GetId()*NI.GetId() % NNodes); } // test node data for (TNodeEdgeNet<TInt, TInt>::TNodeI NI = Net->BegNI(); NI < Net->EndNI(); NI++) { EXPECT_EQ((NI.GetId()*NI.GetId()) % NNodes, Net->GetNDat(NI.GetId())); } // test sorting of node IDs (unsorted) Min = -1; Sorted = true; for (TNodeEdgeNet<TInt, TInt>::TNodeI NI = Net->BegNI(); NI < Net->EndNI(); NI++) { Value = NI.GetId(); if (Min > Value) { Sorted = false; } Min = Value; } EXPECT_EQ(false,Sorted); // sort the nodes by node IDs (sorted) Net->SortNIdById(); // test sorting of node IDs Min = -1; Sorted = true; for (TNodeEdgeNet<TInt, TInt>::TNodeI NI = Net->BegNI(); NI < Net->EndNI(); NI++) { Value = NI.GetId(); if (Min > Value) { Sorted = false; } Min = Value; } EXPECT_EQ(true,Sorted); // test sorting of node data (unsorted) Min = -1; Sorted = true; for (TNodeEdgeNet<TInt, TInt>::TNodeI NI = Net->BegNI(); NI < Net->EndNI(); NI++) { Value = Net->GetNDat(NI.GetId()); if (Min > Value) { Sorted = false; } Min = Value; } EXPECT_EQ(false,Sorted); // sort the nodes by node data Net->SortNIdByDat(); // test sorting of node data (sorted) Min = -1; Sorted = true; for (TNodeEdgeNet<TInt, TInt>::TNodeI NI = Net->BegNI(); NI < Net->EndNI(); NI++) { Value = Net->GetNDat(NI.GetId()); if (Min > Value) { Sorted = false; } Min = Value; } EXPECT_EQ(true,Sorted); // test sorting of node IDs (unsorted) Min = -1; Sorted = true; for (TNodeEdgeNet<TInt, TInt>::TNodeI NI = Net->BegNI(); NI < Net->EndNI(); NI++) { Value = NI.GetId(); if (Min > Value) { Sorted = false; } Min = Value; } EXPECT_EQ(false,Sorted); // test node data for (TNodeEdgeNet<TInt, TInt>::TNodeI NI = Net->BegNI(); NI < Net->EndNI(); NI++) { EXPECT_EQ((NI.GetId()*NI.GetId()) % NNodes, Net->GetNDat(NI.GetId())); } }
// Test update edge data TEST(TNodeEdgeNet, UpdateEdgeData) { int NNodes = 10000; int NEdges = 100000; TPt <TNodeEdgeNet<TInt, TInt> > Net; TPt <TNodeEdgeNet<TInt, TInt> > Net1; TPt <TNodeEdgeNet<TInt, TInt> > Net2; int i; int n; int NCount; int x,y; Net = TNodeEdgeNet<TInt, TInt>::New(); EXPECT_EQ(1,Net->Empty()); // create the nodes for (i = 0; i < NNodes; i++) { Net->AddNode(i); } EXPECT_EQ(0,Net->Empty()); EXPECT_EQ(NNodes,Net->GetNodes()); // create random edges and edge data x+y+10 NCount = NEdges; while (NCount > 0) { x = (long) (drand48() * NNodes); y = (long) (drand48() * NNodes); n = Net->AddEdge(x, y, -1, x+y+10); // printf("0a %d %d %d\n",x,y,n); NCount--; } EXPECT_EQ(NEdges,Net->GetEdges()); EXPECT_EQ(0,Net->Empty()); EXPECT_EQ(1,Net->IsOk()); for (i = 0; i < NNodes; i++) { EXPECT_EQ(1,Net->IsNode(i)); } EXPECT_EQ(0,Net->IsNode(NNodes)); EXPECT_EQ(0,Net->IsNode(NNodes+1)); EXPECT_EQ(0,Net->IsNode(2*NNodes)); // add data to nodes, square of node ID for (TNodeEdgeNet<TInt, TInt>::TNodeI NI = Net->BegNI(); NI < Net->EndNI(); NI++) { Net->SetNDat(NI.GetId(), NI.GetId()*NI.GetId()); } // test node data for (TNodeEdgeNet<TInt, TInt>::TNodeI NI = Net->BegNI(); NI < Net->EndNI(); NI++) { EXPECT_EQ(NI.GetId()*NI.GetId(), Net->GetNDat(NI.GetId())); } // verify edge data, x+y+10 for (TNodeEdgeNet<TInt, TInt>::TEdgeI EI = Net->BegEI(); EI < Net->EndEI(); EI++) { EXPECT_EQ(EI.GetSrcNId()+EI.GetDstNId()+10, Net->GetEDat(EI.GetId())); } // update edge data, x+y+5 for (TNodeEdgeNet<TInt, TInt>::TEdgeI EI = Net->BegEI(); EI < Net->EndEI(); EI++) { Net->SetEDat(EI.GetId(),EI.GetSrcNId()+EI.GetDstNId()+5); } // verify edge data, x+y+5 for (TNodeEdgeNet<TInt, TInt>::TEdgeI EI = Net->BegEI(); EI < Net->EndEI(); EI++) { EXPECT_EQ(EI.GetSrcNId()+EI.GetDstNId()+5, Net->GetEDat(EI.GetId())); } // test node data again for (TNodeEdgeNet<TInt, TInt>::TNodeI NI = Net->BegNI(); NI < Net->EndNI(); NI++) { EXPECT_EQ(NI.GetId()*NI.GetId(), Net->GetNDat(NI.GetId())); } }
// Test node, edge creation TEST(TNodeEdgeNet, ManipulateNodesEdges) { int NNodes = 10000; int NEdges = 100000; const char *FName = "test.net"; TPt <TNodeEdgeNet<TInt, TInt> > Net; TPt <TNodeEdgeNet<TInt, TInt> > Net1; TPt <TNodeEdgeNet<TInt, TInt> > Net2; int i; int n; int NCount; int x,y; int Deg, InDeg, OutDeg; Net = TNodeEdgeNet<TInt, TInt>::New(); EXPECT_EQ(1,Net->Empty()); // create the nodes for (i = 0; i < NNodes; i++) { Net->AddNode(i); } EXPECT_EQ(0,Net->Empty()); EXPECT_EQ(NNodes,Net->GetNodes()); // create random edges NCount = NEdges; while (NCount > 0) { x = (long) (drand48() * NNodes); y = (long) (drand48() * NNodes); n = Net->AddEdge(x, y); NCount--; } EXPECT_EQ(NEdges,Net->GetEdges()); EXPECT_EQ(0,Net->Empty()); EXPECT_EQ(1,Net->IsOk()); for (i = 0; i < NNodes; i++) { EXPECT_EQ(1,Net->IsNode(i)); } EXPECT_EQ(0,Net->IsNode(NNodes)); EXPECT_EQ(0,Net->IsNode(NNodes+1)); EXPECT_EQ(0,Net->IsNode(2*NNodes)); // nodes iterator NCount = 0; for (TNodeEdgeNet<TInt, TInt>::TNodeI NI = Net->BegNI(); NI < Net->EndNI(); NI++) { NCount++; } EXPECT_EQ(NNodes,NCount); // edges per node iterator NCount = 0; for (TNodeEdgeNet<TInt, TInt>::TNodeI NI = Net->BegNI(); NI < Net->EndNI(); NI++) { for (int e = 0; e < NI.GetOutDeg(); e++) { NCount++; } } EXPECT_EQ(NEdges,NCount); // edges iterator NCount = 0; for (TNodeEdgeNet<TInt, TInt>::TEdgeI EI = Net->BegEI(); EI < Net->EndEI(); EI++) { NCount++; } EXPECT_EQ(NEdges,NCount); // node degree for (TNodeEdgeNet<TInt, TInt>::TNodeI NI = Net->BegNI(); NI < Net->EndNI(); NI++) { Deg = NI.GetDeg(); InDeg = NI.GetInDeg(); OutDeg = NI.GetOutDeg(); EXPECT_EQ(Deg,InDeg+OutDeg); } // assignment Net1 = TNodeEdgeNet<TInt, TInt>::New(); *Net1 = *Net; EXPECT_EQ(NNodes,Net1->GetNodes()); EXPECT_EQ(NEdges,Net1->GetEdges()); EXPECT_EQ(0,Net1->Empty()); EXPECT_EQ(1,Net1->IsOk()); // saving and loading { TFOut FOut(FName); Net->Save(FOut); FOut.Flush(); } { TFIn FIn(FName); Net2 = TNodeEdgeNet<TInt, TInt>::Load(FIn); } EXPECT_EQ(NNodes,Net2->GetNodes()); EXPECT_EQ(NEdges,Net2->GetEdges()); EXPECT_EQ(0,Net2->Empty()); EXPECT_EQ(1,Net2->IsOk()); // remove all the nodes and edges for (i = 0; i < NNodes; i++) { n = Net->GetRndNId(); Net->DelNode(n); } EXPECT_EQ(0,Net->GetNodes()); EXPECT_EQ(0,Net->GetEdges()); EXPECT_EQ(1,Net->IsOk()); EXPECT_EQ(1,Net->Empty()); Net1->Clr(); EXPECT_EQ(0,Net1->GetNodes()); EXPECT_EQ(0,Net1->GetEdges()); EXPECT_EQ(1,Net1->IsOk()); EXPECT_EQ(1,Net1->Empty()); }
// Print network statistics void PrintNStats(const char s[], TPt <TNodeEDatNet<TInt, TInt> > Net) { printf("network %s, nodes %d, edges %d, empty %s\n", s, Net->GetNodes(), Net->GetEdges(), Net->Empty() ? "yes" : "no"); }