forked from aepasto/triest
-
Notifications
You must be signed in to change notification settings - Fork 0
/
GraphScheduler.h
64 lines (51 loc) · 1 KB
/
GraphScheduler.h
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/*
* GraphScheduler.h
*
* Created on: Oct 22, 2014
* Author: aepasto
*/
#ifndef GRAPHSCHEDULER_H_
#define GRAPHSCHEDULER_H_
#include <algorithm>
#include <vector>
#include <queue>
#include <fstream>
using namespace std;
//Number of lines read each time
#define CHUNK_SIZE 10000
enum Update {
ADD, REM
};
typedef struct EdgeUpdate {
int node_u;
int node_v;
int time;
bool is_add;
} EdgeUpdate;
typedef struct EdgeUpdateNoTime {
int node_u;
int node_v;
bool is_add;
} EdgeUpdateNoTime;
class GraphScheduler {
public:
GraphScheduler(const string& file_name, bool store_time_);
virtual ~GraphScheduler();
EdgeUpdate next_update();
inline bool has_next() {
if (store_time_) {
return !edge_queue_.empty();
} else {
return !edge_queue_no_time_.empty();
}
}
private:
bool store_time_;
int add_count;
int remove_count;
void retrieve_next_chunk();
ifstream file_stream_;
queue<EdgeUpdate> edge_queue_;
queue<EdgeUpdateNoTime> edge_queue_no_time_;
};
#endif /* GRAPHSCHEDULER_H_ */