本文整理汇总了C++中PNEANet::DelNode方法的典型用法代码示例。如果您正苦于以下问题:C++ PNEANet::DelNode方法的具体用法?C++ PNEANet::DelNode怎么用?C++ PNEANet::DelNode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PNEANet
的用法示例。
在下文中一共展示了PNEANet::DelNode方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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());
}
}
示例2: ManipulateNodesEdges
// Test node, edge creation
void ManipulateNodesEdges() {
int NNodes = 1000;
int NEdges = 100000;
const char *FName = "demo.graph.dat";
PNEANet Graph;
PNEANet Graph1;
PNEANet Graph2;
int i;
int n;
int NCount;
int ECount1;
int ECount2;
int x,y;
bool t;
Graph = TNEANet::New();
t = Graph->Empty();
// create the nodes
for (i = 0; i < NNodes; i++) {
Graph->AddNode(i);
}
n = Graph->GetNodes();
t = Graph->Empty();
// create random edges
NCount = NEdges;
while (NCount > 0) {
x = rand() % NNodes;
y = rand() % NNodes;
n = Graph->AddEdge(x, y);
NCount--;
}
PrintGStats("ManipulateNodesEdges:Graph",Graph);
// get all the nodes
NCount = 0;
for (TNEANet::TNodeI NI = Graph->BegNI(); NI < Graph->EndNI(); NI++) {
NCount++;
}
// get all the edges for all the nodes
ECount1 = 0;
for (TNEANet::TNodeI NI = Graph->BegNI(); NI < Graph->EndNI(); NI++) {
for (int e = 0; e < NI.GetOutDeg(); e++) {
ECount1++;
}
}
// get all the edges directly
ECount2 = 0;
for (TNEANet::TEdgeI EI = Graph->BegEI(); EI < Graph->EndEI(); EI++) {
ECount2++;
}
printf("graph ManipulateNodesEdges:Graph, nodes %d, edges1 %d, edges2 %d\n",
NCount, ECount1, ECount2);
// assignment
Graph1 = TNEANet::New();
*Graph1 = *Graph;
PrintGStats("ManipulateNodesEdges:Graph1",Graph1);
// save the graph
{
TFOut FOut(FName);
Graph->Save(FOut);
FOut.Flush();
}
// load the graph
{
TFIn FIn(FName);
Graph2 = TNEANet::Load(FIn);
}
PrintGStats("ManipulateNodesEdges:Graph2",Graph2);
// remove all the nodes and edges
for (i = 0; i < NNodes; i++) {
n = Graph->GetRndNId();
Graph->DelNode(n);
}
PrintGStats("ManipulateNodesEdges:Graph",Graph);
Graph1->Clr();
PrintGStats("ManipulateNodesEdges:Graph1",Graph1);
}
示例3: FOut
//.........这里部分代码省略.........
// create random edges
NCount = NEdges;
while (NCount > 0) {
x = (long) (drand48() * NNodes);
y = (long) (drand48() * NNodes);
n = Graph->AddEdge(x, y);
NCount--;
}
EXPECT_EQ(NEdges,Graph->GetEdges());
EXPECT_EQ(0,Graph->Empty());
EXPECT_EQ(1,Graph->IsOk());
for (i = 0; i < NNodes; i++) {
EXPECT_EQ(1,Graph->IsNode(i));
}
EXPECT_EQ(0,Graph->IsNode(NNodes));
EXPECT_EQ(0,Graph->IsNode(NNodes+1));
EXPECT_EQ(0,Graph->IsNode(2*NNodes));
// nodes iterator
NCount = 0;
for (TNEANet::TNodeI NI = Graph->BegNI(); NI < Graph->EndNI(); NI++) {
NCount++;
}
EXPECT_EQ(NNodes,NCount);
// edges per node iterator
NCount = 0;
for (TNEANet::TNodeI NI = Graph->BegNI(); NI < Graph->EndNI(); NI++) {
for (int e = 0; e < NI.GetOutDeg(); e++) {
NCount++;
}
}
EXPECT_EQ(NEdges,NCount);
// edges iterator
NCount = 0;
for (TNEANet::TEdgeI EI = Graph->BegEI(); EI < Graph->EndEI(); EI++) {
NCount++;
}
EXPECT_EQ(NEdges,NCount);
// node degree
for (TNEANet::TNodeI NI = Graph->BegNI(); NI < Graph->EndNI(); NI++) {
Deg = NI.GetDeg();
InDeg = NI.GetInDeg();
OutDeg = NI.GetOutDeg();
EXPECT_EQ(Deg,InDeg+OutDeg);
}
// assignment
Graph1 = TNEANet::New();
*Graph1 = *Graph;
EXPECT_EQ(NNodes,Graph1->GetNodes());
EXPECT_EQ(NEdges,Graph1->GetEdges());
EXPECT_EQ(0,Graph1->Empty());
EXPECT_EQ(1,Graph1->IsOk());
// saving and loading
{
TFOut FOut(FName);
Graph->Save(FOut);
FOut.Flush();
}
{
TFIn FIn(FName);
Graph2 = TNEANet::Load(FIn);
}
EXPECT_EQ(NNodes,Graph2->GetNodes());
EXPECT_EQ(NEdges,Graph2->GetEdges());
EXPECT_EQ(0,Graph2->Empty());
EXPECT_EQ(1,Graph2->IsOk());
// remove all the nodes and edges
for (i = 0; i < NNodes; i++) {
n = Graph->GetRndNId();
Graph->DelNode(n);
}
EXPECT_EQ(0,Graph->GetNodes());
EXPECT_EQ(0,Graph->GetEdges());
EXPECT_EQ(1,Graph->IsOk());
EXPECT_EQ(1,Graph->Empty());
Graph1->Clr();
EXPECT_EQ(0,Graph1->GetNodes());
EXPECT_EQ(0,Graph1->GetEdges());
EXPECT_EQ(1,Graph1->IsOk());
EXPECT_EQ(1,Graph1->Empty());
}