本文整理汇总了C++中PNEANet::Clr方法的典型用法代码示例。如果您正苦于以下问题:C++ PNEANet::Clr方法的具体用法?C++ PNEANet::Clr怎么用?C++ PNEANet::Clr使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PNEANet
的用法示例。
在下文中一共展示了PNEANet::Clr方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: BuildCapacityNetwork
int BuildCapacityNetwork(const TStr& InFNm, PNEANet &Net, const int& SrcColId = 0, const int& DstColId = 1, const int& CapColId = 2) {
TSsParser Ss(InFNm, ssfWhiteSep, true, true, true);
TRnd Random;
Net.Clr();
Net = TNEANet::New();
int SrcNId, DstNId, CapVal, EId;
int MaxCap = 0;
while (Ss.Next()) {
if (! Ss.GetInt(SrcColId, SrcNId) || ! Ss.GetInt(DstColId, DstNId)) { continue; }
Ss.GetInt(CapColId, CapVal);
//CapVal = Random.GetUniDevInt(1, 10000);
MaxCap = max(CapVal, MaxCap);
if (! Net->IsNode(SrcNId)) {
Net->AddNode(SrcNId);
}
if (! Net->IsNode(DstNId)) {
Net->AddNode(DstNId);
}
EId = Net->AddEdge(SrcNId, DstNId);
Net->AddIntAttrDatE(EId, CapVal, TSnap::CapAttrName);
}
Net->Defrag();
return MaxCap;
}
示例2: ManipulateNodeEdgeAttributes
//.........这里部分代码省略.........
printf("Vertical Node (no str) : %i, Attr: %s\n", NId, NIdAttrName[i]());
}
TStrV NIdAttrValue;
Graph->AttrValueNI(NId, NIdAttrValue);
AttrLen = NIdAttrValue.Len();
for (int i = 0; i < AttrLen; i++) {
printf("Vertical Node (no str) : %i, Attr_Val: %s\n", NId, NIdAttrValue[i]());
}
for (i = 0; i <NNodes; i++) {
Graph->AddIntAttrDatN(i, 70, attr2);
}
{
TFOut FOut(FName);
Graph->Save(FOut);
FOut.Flush();
}
{
TFIn FIn(FName);
Graph1 = TNEANet::Load(FIn);
}
int total = 0;
for (TNEANet::TAIntI NI = Graph1->BegNAIntI(attr2);
NI < Graph1->EndNAIntI(attr2); NI++) {
total += NI.GetDat();
}
printf("Average: %i (should be 70)\n", total/NNodes);
Graph1->Clr();
// Test vertical int iterator for edge
Graph->AddIntAttrDatE(3, 3*2, attr2);
Graph->AddIntAttrDatE(55, 55*2, attr2);
Graph->AddIntAttrDatE(705, 705*2, attr2);
Graph->AddIntAttrDatE(905, 905*2, attr2);
int EdgeId = 0;
for (TNEANet::TAIntI EI = Graph->BegEAIntI(attr2);
EI < Graph->EndEAIntI(attr2); EI++) {
if (EI.GetDat() != TInt::Mn) {
printf("E Attribute: %s, Edge: %i, Val: %i\n", attr2(), EdgeId, EI.GetDat()());
EdgeId++;
}
}
// Test vertical flt iterator for edge
Graph->AddFltAttrE(attr3, 0.00);
Graph->AddFltAttrDatE(5, 4.41, attr3);
Graph->AddFltAttrDatE(50, 3.718, attr3);
Graph->AddFltAttrDatE(300, 151.0, attr3);
Graph->AddFltAttrDatE(653, 654, attr3);
EdgeId = 0;
for (TNEANet::TAFltI EI = Graph->BegEAFltI(attr3);
EI < Graph->EndEAFltI(attr3); EI++) {
// Check if defaults are set to 0.
if (EI.GetDat() != 0.00) {
printf("E Attribute: %s, Edge: %i, Val: %f\n", attr3(), EdgeId, EI.GetDat()());
EdgeId++;
}
}
// Test vertical str iterator for edge
示例3: FOut
//.........这里部分代码省略.........
for (i = 0; i < AttrLen; i++) {
if (TStr("str") == NIdAttrValue[i]()) {
// FAIL
EXPECT_EQ(1,2);
}
}
int expectedTotal = 0;
for (i = 0; i <NNodes; i++) {
Graph->AddIntAttrDatN(i, NNodes+i, attr2);
EXPECT_EQ(NNodes+i, Graph->GetIntAttrDatN(i, attr2));
expectedTotal += NNodes+i;
}
{
TFOut FOut(FName);
Graph->Save(FOut);
FOut.Flush();
}
{
TFIn FIn(FName);
Graph1 = TNEANet::Load(FIn);
}
int total = 0;
for (TNEANet::TAIntI NI = Graph1->BegNAIntI(attr2);
NI < Graph1->EndNAIntI(attr2); NI++) {
total += NI.GetDat();
}
ASSERT_EQ(expectedTotal, total);
Graph1->Clr();
// Test vertical int iterator for edge
Graph->AddIntAttrDatE(3, 3*2, attr2);
Graph->AddIntAttrDatE(55, 55*2, attr2);
Graph->AddIntAttrDatE(705, 705*2, attr2);
Graph->AddIntAttrDatE(905, 905*2, attr2);
EXPECT_EQ(3*2, Graph->GetEAIntI(attr2, 3).GetDat());
EXPECT_EQ(55*2, Graph->GetEAIntI(attr2, 55).GetDat());
int EdgeId = 0;
int DefEdges = 0;
TAIntIV.Clr();
for (TNEANet::TAIntI EI = Graph->BegEAIntI(attr2);
EI < Graph->EndEAIntI(attr2); EI++) {
if (EI.GetDat() != TInt::Mn) {
TAIntIV.Add(EI.GetDat());
EdgeId++;
} else {
DefEdges++;
}
}
EXPECT_EQ(4, EdgeId);
EXPECT_EQ(NEdges - 4, DefEdges);
TAIntIV.Sort();
EXPECT_EQ(3*2, TAIntIV[0]);
EXPECT_EQ(55*2, TAIntIV[1]);
EXPECT_EQ(705*2, TAIntIV[2]);
EXPECT_EQ(905*2, TAIntIV[3]);
// Test vertical flt iterator for edge