本文整理汇总了C++中TRnd::PutSeed方法的典型用法代码示例。如果您正苦于以下问题:C++ TRnd::PutSeed方法的具体用法?C++ TRnd::PutSeed怎么用?C++ TRnd::PutSeed使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TRnd
的用法示例。
在下文中一共展示了TRnd::PutSeed方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: test
bool test(PGraph &graph, bool followOut, bool followIn) {
printf("\n================================\nFollowOut: %d, FollowIn: %d\n", followOut, followIn);
int iters = 10;
for (int k = 0; k < iters; k++) {
TRnd rnd = TRnd((int)time(0));
int start = graph->GetRndNId(rnd);
rnd.PutSeed(0);
// int target = graph->GetRndNId(rnd);
// printf("Start node: %d, target node: %d\n", start, target);
int target = -1;
printf("Start node: %d\n", start);
struct timeval tv1, tv2;
gettimeofday(&tv1, NULL);
/* Hybrid */
TBreathFS<PGraph> bfs_hybrid(graph, true);
int maxDist_hybrid = bfs_hybrid.DoBfsHybrid(start, followOut, followIn, target);
gettimeofday(&tv2, NULL);
double time_hybrid = timeInSeconds(tv1, tv2);
/* Original */
gettimeofday(&tv1, NULL);
TBreathFS<PGraph> bfs(graph, true);
int maxDist = bfs.DoBfs(start, followOut, followIn, target);
gettimeofday(&tv2, NULL);
double time = timeInSeconds(tv1, tv2);
/* Check results */
if (maxDist_hybrid != maxDist) {
printf("MaxDist incorrect.\n");
return false;
}
if (target == -1) {
if (!checkResults<PGraph>(bfs_hybrid, bfs)) {
printf("NIdDistH values incorrect!\n");
return false;
}
}
printf("Execution times: Original: %.2f, Hybrid: %.2f\n", time, time_hybrid);
}
return true;
}