Skip to content

Commit

Permalink
hyperanf: clean code
Browse files Browse the repository at this point in the history
  • Loading branch information
zzjjzzgggg committed Mar 5, 2020
1 parent c356cad commit a71eb9e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 15 deletions.
1 change: 0 additions & 1 deletion graph/hyperanf.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ class HyperANF {
for (int n = 0; n < num; n++) {
uint64_t x = rng.randint<uint64_t>();
int reg_idx = (x >> (64 - p_)) & ((1 << p_) - 1);
// uint8_t reg_rho = hll::clz8(x << p_ | 1 << (p_ - 1)) + 1;
uint8_t reg_rho = hll::clz8(x << p_) + 1;
if (reg_rho > reg_array[reg_idx]) reg_array[reg_idx] = reg_rho;
}
Expand Down
20 changes: 6 additions & 14 deletions test/test_hyperanf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,26 +24,18 @@ void test_anf_single() {
anf.initBitsCC(graph);
printf("ANF: %.4fs\n", tm.seconds());

printf("nd\ttruth\ttime\test\ttime\terror(%%)\n");
printf("nd\ttruth\test\terror\n");

// auto fw = ioutils::getIOOut("hepth_anf.dat");
for (int i = 0; i < 100; i++) {
int nd = graph.sampleNode();
for (auto ni = graph.beginNI(); ni != graph.endNI(); ni++) {
int nd = ni->first;

tm.tick();
bfs.doBFS(nd);
int truth = bfs.getBFSTreeSize();
double t1 = tm.seconds();

tm.tick();
int truth = bfs.getBFSTreeSize();
double est = anf.estimate(nd);
double t2 = tm.seconds();

double err = std::abs(est - truth) / truth * 100;
double err = std::abs(est - truth) / truth;

printf("%d\t%d\t%.2e\t%.2f\t%.2e\t%.2f\n", nd, truth, t1, est, t2, err);
// fw->save("{:d}\t{:d}\t{:.3e}\t{:.3f}\t{:.3e}\t{:.2f}\n"_format(
// nd, truth, t1, est, t2, err));
printf("%d\t%d\t%.2f\t%.4f\n", nd, truth, est, err);
}
}

Expand Down

0 comments on commit a71eb9e

Please sign in to comment.