-
Notifications
You must be signed in to change notification settings - Fork 0
/
BFS_cascade.hpp
38 lines (33 loc) · 1015 Bytes
/
BFS_cascade.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#pragma once
#include <random>
#include "graph.hpp"
#include "bfs.hpp"
#include "parlay/sequence.h"
#include "utilities.h"
using namespace std;
struct GeneralCascade {
private:
BFS& BFS_simulate;
public:
GeneralCascade(BFS& _bfs) : BFS_simulate(_bfs) {}
double Run(const parlay::sequence<NodeId>& seeds, int num_iter) {
cout << seeds.size() << " seeds: ";
for (auto s: seeds){
cout << s << " ";
}
cout << endl;
size_t influence = 0;
BFS_simulate.rand_seed = 0;
for (int i = 0; i<num_iter; i++){
Hash_Edge hash_edge = {_hash((EdgeId) i)};
size_t single_spread = BFS_simulate.bfs(seeds, hash_edge);
// size_t check_spread = BFS_simulate.bfs_sequence(seeds, hash_edge);
// if (single_spread != check_spread){
// cout << "check failed " << single_spread << " " << check_spread << endl;
// }
influence+= single_spread;
BFS_simulate.rand_seed += BFS_simulate.get_m();
}
return influence / (num_iter+0.0);
}
};