本文整理汇总了C++中TPt::SortEIdById方法的典型用法代码示例。如果您正苦于以下问题:C++ TPt::SortEIdById方法的具体用法?C++ TPt::SortEIdById怎么用?C++ TPt::SortEIdById使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TPt
的用法示例。
在下文中一共展示了TPt::SortEIdById方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
// 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;
//.........这里部分代码省略.........