本文整理汇总了C++中PNEANet::GetNAFltI方法的典型用法代码示例。如果您正苦于以下问题:C++ PNEANet::GetNAFltI方法的具体用法?C++ PNEANet::GetNAFltI怎么用?C++ PNEANet::GetNAFltI使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PNEANet
的用法示例。
在下文中一共展示了PNEANet::GetNAFltI方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: FOut
// Test node, edge attribute functionality
TEST(TNEANet, ManipulateNodesEdgeAttributes) {
int NNodes = 1000;
int NEdges = 1000;
const char *FName = "demo.graph.dat";
PNEANet Graph;
PNEANet Graph1;
int i;
int x, y;
bool t;
Graph = TNEANet::New();
t = Graph->Empty();
// create the nodes
for (i = NNodes - 1; i >= 0; i--) {
Graph->AddNode(i);
}
EXPECT_EQ(NNodes, Graph->GetNodes());
// create the edges
for (i = NEdges - 1; i >= 0; i--) {
x = (long) (drand48() * NNodes);
y = (long) (drand48() * NNodes);
Graph->AddEdge(x, y, i);
}
// create attributes and fill all nodes
TStr attr1 = "str";
TStr attr2 = "int";
TStr attr3 = "float";
TStr attr4 = "default";
// Test vertical int iterator for node 3, 50, 700, 900
// Check if we can set defaults to 0 for Int data.
Graph->AddIntAttrN(attr2, 0);
Graph->AddIntAttrDatN(3, 3*2, attr2);
Graph->AddIntAttrDatN(50, 50*2, attr2);
Graph->AddIntAttrDatN(700, 700*2, attr2);
Graph->AddIntAttrDatN(900, 900*2, attr2);
EXPECT_EQ(3*2, Graph->GetNAIntI(attr2, 3).GetDat());
EXPECT_EQ(50*2, Graph->GetNAIntI(attr2, 50).GetDat());
int NodeId = 0;
int DefNodes = 0;
TVec<TInt> TAIntIV = TVec<TInt>();
for (TNEANet::TAIntI NI = Graph->BegNAIntI(attr2);
NI < Graph->EndNAIntI(attr2); NI++) {
if (NI.GetDat()() != 0) {
TAIntIV.Add(NI.GetDat());
NodeId++;
} else {
DefNodes++;
}
}
EXPECT_EQ(4, NodeId);
EXPECT_EQ(NNodes - 4, DefNodes);
TAIntIV.Sort();
EXPECT_EQ(3*2, TAIntIV[0]);
EXPECT_EQ(50*2, TAIntIV[1]);
EXPECT_EQ(700*2, TAIntIV[2]);
EXPECT_EQ(900*2, TAIntIV[3]);
// Test vertical flt iterator for node 3, 50, 700, 900
Graph->AddFltAttrDatN(5, 3.41, attr3);
Graph->AddFltAttrDatN(50, 2.718, attr3);
Graph->AddFltAttrDatN(300, 150.0, attr3);
Graph->AddFltAttrDatN(653, 563, attr3);
EXPECT_EQ(3.41, Graph->GetNAFltI(attr3, 5).GetDat());
EXPECT_EQ(2.718, Graph->GetNAFltI(attr3, 50).GetDat());
NodeId = 0;
DefNodes = 0;
TVec<TFlt> TAFltIV = TVec<TFlt>();
for (TNEANet::TAFltI NI = Graph->BegNAFltI(attr3);
NI < Graph->EndNAFltI(attr3); NI++) {
if (NI.GetDat() != TFlt::Mn) {
NodeId++;
TAFltIV.Add(NI.GetDat());
} else {
DefNodes++;
}
}
EXPECT_EQ(4, NodeId);
EXPECT_EQ(NNodes - 4, DefNodes);
TAFltIV.Sort();
EXPECT_EQ(2.718, TAFltIV[0]);
EXPECT_EQ(3.41, TAFltIV[1]);
EXPECT_EQ(150.0, TAFltIV[2]);
EXPECT_EQ(563.0, TAFltIV[3]);
// Test vertical str iterator for node 3, 50, 700, 900
Graph->AddStrAttrDatN(10, "abc", attr1);
//.........这里部分代码省略.........