-
Notifications
You must be signed in to change notification settings - Fork 0
/
Universe.h
146 lines (116 loc) · 3.33 KB
/
Universe.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
/*Universe.h*/
#ifndef _UNIVERSE_H_
#define _UNIVERSE_H_
#include <iostream>
#include <fstream>
using namespace std;
#include <vector>
#include <set>
#include <hash_set>
#include <hash_map>
#include <stack>
#include <queue>
#include "Rand.h"
#include "RTree.h"
#include <iterator>
#include <time.h>
#include <sstream>
struct Location
{
double x, y;
Location(double a, double b)
{
x = a;
y = b;
}
Location()
{
x = 0;
y = 0;
}
};
struct MyRect
{
Location left_bottom;
Location right_top;
MyRect(double minx, double miny, double maxx, double maxy)
{
left_bottom.x = minx;
left_bottom.y = miny;
right_top.x = maxx;
right_top.y = maxy;
}
MyRect()
{
left_bottom.x = 0;
left_bottom.y = 0;
right_top.x = 0;
right_top.y = 0;
}
};
struct Entity
{
int id;
bool IsSpatial;
Location location;
int type;
MyRect RMBR;
int scc_id;
};
struct Rect
{
Rect() {}
Rect(double a_minX, double a_minY, double a_maxX, double a_maxY)
{
min[0] = a_minX;
min[1] = a_minY;
max[0] = a_maxX;
max[1] = a_maxY;
}
double min[2];
double max[2];
};
struct edge
{
int edge_type;
int vertex;
};
bool MySearchCallback(int id, void* arg);
vector<int> GetHitID();
void ResetHitID(int size);
int GetStartTime();
void SetStartTime(int i);
int GetRunTime();
void SetRunTime(int i);
//Judge whether a location is in a specific rectangle
bool Location_In_Rect(Location m_location, MyRect m_rect);
//Outfile entity to disk for storage
void EntityToDisk(Entity Entity_Matrix[], int node_count, int range, string filename);
void EntityToDisk(vector<Entity> entity_vector, int range, string filename);
//Out file entity to disk for displaying
void OutFile(Entity Entity_Matrix[], int node_count, string filename);
void OutFile(vector<Entity> &entity_vector, string filename);
//Generate entity with specific spatial entity ratio
void GenerateEntity(int node_count, Entity Entity_Matrix[], int range, double nonspatial_entity_ratio);
void GenerateEntity(int node_count, vector<Entity> &entity_vector, int range, double nonspatial_entity_ratio);
//Read entity from disk storage
void ReadEntityFromDisk(int &node_count, Entity Entity_Matrix[], int &range,string filename);
void ReadEntityFromDisk(int &node_count, vector<Entity> &entity_vector, int &range, string filename);
void ReadEntityInSCCFromDisk(int &node_count, vector<Entity> &entity_vector, int &range, string filename);
void ReadEntityInSCCSeperateFromDisk(int &node_count, vector<Entity> &entity_vector, int &range, string filename);
void EntityInSCCSeperate_To_Disk(vector<Entity> &entity_vector, int range, string filename);
void EntityInSCC_To_Disk(vector<Entity> &entity_vector, int range, string filename);
//Entity to new format
void EntityInSCCToNewFormat(int &node_count, vector<Entity> &entity_vector, int &range, string filename, string newfilename);
string getstring(const int i);
int StringtoInt(string str);
vector<string> split(string str, string pattern);
//Topological sort of dag
void TopologicalSortUtil(int v, vector<bool> &visited, queue<int> &Queue, vector<vector<int>> &graph);
void TopologicalSort(vector<vector<int>> &graph, queue<int> &Queue);
//Get in_edge graph
void GenerateInedgeGraph(vector<vector<int>> &graph, vector<vector<int>> &in_edge_graph);
//GenerateGauss
double randomGauss(double mean, double sigma, TRnd &rand);
int randomSkewed(int p, double HsubV, TRnd &rand);
#endif