-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathDef.h
362 lines (269 loc) · 7.67 KB
/
Def.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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
/*
Algorithm: Micro-cluster based DBSCAN
Author: Aditya Sarma
email: asaditya1195@gmail.com
*/
#ifndef _DEF_H
#define _DEF_H
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <sys/time.h>
#include <sys/stat.h>
#include <assert.h>
#include <math.h>
#include <sched.h>
#include <float.h>
#include <mpi.h>
#include <vector>
using namespace std;
#define LOWER(i) (i<<1)
#define UPPER(i) ((i<<1)+1)
#define DELIM " " //Delimiter in the input file
#define LEFT(x) (2 * (x) + 1)
#define RIGHT(x) (2 * (x) + 2)
#define PARENT(x) ((x-1) / 2)
#define DEBUG 0
#define proc_of_interest 0
#define PRINT 0
#define ASSERT(x) assert(x!=NULL)
#define NOISE 0
#define POW2(x) (1 << (x))
typedef struct interval* Interval;
typedef struct pointelem* PointElem;
typedef struct pointHdr* PointHdr;
typedef struct data* Data; // Structure holding the data of each element
typedef struct dataHdr* DataHdr;// Head Node for the list of data elements
//to store neighbours
typedef double* DataPoint; // type of pointer to data point
typedef double dataPoint; // type of data point
typedef struct region* Region; // type of pointer to structure for rectangle
typedef struct clusterds* ClusterDS; // datatype for pointer to structure for cluster
typedef double *Dimension; //type of pointer to one corner of rectangle
typedef double dimension; //type of corner of rectangle
typedef double *Double; //type of pointer to double
typedef int RecNum;
typedef struct RhdrNd* RHdrNd; // Head Node for a list of children of RTree
typedef struct RlstNd* RLstNd;
typedef struct RtreeData* RTreeData; // type of pointer to Data in tree node
typedef struct RtreeNode* RTreeNode;
typedef struct RnbHdr* RNbHdr;
typedef struct Rnb* RNB;
typedef struct group* Group;
typedef struct bcell* BCell;
typedef struct celldatahd* CellDataHd;
typedef struct celldata* CellData;
typedef struct bcelllistnode* BCellListNode;
typedef struct bcelllisthd* BCellListHd;
typedef struct Kdtree* KdTree;
typedef struct KNNdistnode* KNNDistNode;
typedef struct GhdrNd* GHdrNd; // Head Node for a list of children of RTree
typedef struct GlstNd* GLstNd; // Nodes in the list of children of RTree node
typedef struct GtreeData* GTreeData; // type of pointer to Data in tree node
typedef struct GtreeNode* GTreeNode; // type of pointer to tree node
typedef struct vectorc vectorc;
typedef struct assign* Assign;
typedef struct neighbours* Neighbours;
#ifndef EXTERN_H
#define EXTERN_H
extern double EPS;
extern int MINPOINTS;
extern int DIMENSION;
extern int GMINENTRIES;
extern int GMAXENTRIES;
extern int GAUXMINENTRIES;
extern int GAUXMAXENTRIES;
extern int RMINENTRIES;
extern int RMAXENTRIES;
extern int CLUSTERID;
extern int GROUPID;
extern int BCELLID;
extern int* addHelper;
extern double* addHelperDouble;
extern struct vectorc* groupList;
extern int** noiseNeighbours;
extern int* visited;
extern int noOfGroups;
extern struct vectorc* reachableGroupCount;
extern int maxReachableGroupCount;
extern int findNeighbourCount;
extern int avgReachableGroupCount;
extern int savedQueries;
extern int totalCore;
extern struct vectorc* unprocessedCore;
extern double * MINGRIDSIZE;
extern double * MAXGRIDSIZE;
extern double * MINGRIDSIZEglobal, *MAXGRIDSIZEglobal;
extern FILE* output;
#endif
struct interval{
double lower,upper;
//float lower, upper;
};
typedef enum{
INTNODE,
EXTNODE
}NODETYPE; // used to mark a node of RTree as internal or external
typedef enum{
NONE,
SPARSEGROUP,
COREGROUP,
MINICLUSTER
}GROUPTYPE;
typedef enum{
FALSE, //
TRUE // 1
} Boolean;
struct result
{
int noise;
int clusters;
int corepoints;
};
typedef enum{INTEGER, GROUP, DOUBLE} VECTORTYPE;
struct ilist
{
int i;
struct ilist* next;
};
typedef struct ilist* iList;
struct dlist
{
double d;
struct dlist* next;
};
typedef struct dlist* dList;
struct neighbours
{
//Replace with linkedlists
int id;
struct vectorc* neighbours_remote_inner;
struct vectorc* neighbours_local_inner;
struct vectorc* neighbours_remote_outer;
struct vectorc* neighbours_local_outer;
int inner_neighbours;
};
// defs for struct assign. This will contain information if a particular point can be
//assigned a group in the current iteration and if yes, then the pointer to that group
struct assign
{
int canBeAssigned;
int groupid;
};
// defs of vector.
struct vectorc
{
Group* groupItems;
int* intItems;
double* doubleItems;
BCell* bcellItems;
int capacity;
int total;
VECTORTYPE type;
};
// defs for data
struct data{
DataPoint iData;
Boolean haloPoint;
int actualProcessId;
int remoteIndex;
int parentId;
int parentProcessId;
int id;
int group_id;
int childCount;
Boolean core_tag;
Boolean isProcessed;
int ClusterID;
Boolean debugPoint;//Debug Variable
int cid;
};
struct dataHdr{ //header for data list
int uiCnt;
int localCnt;
Data dataClstElem;
};
struct region{
Dimension iBottomLeft; // bottom left corner of rectangle
Dimension iTopRight; // top right corner of rectanngle
};
struct clusterds{
int parent;
int rank;
};
//defs for Group
struct group{
int id;
vectorc* inner_points;
vectorc* total_points;
int inner_count;
int total_count;
GROUPTYPE type;
DataPoint master;
int master_id;
BCell bcell; //The BCell formed with the master point at the center of the bcell. i.e. (bottomleft + topright) /(float) 2;
long double threshold;
vectorc* reachable_groups;
vectorc* corepoints;
};
// defining bigger cell
struct bcell{
double * minOriginalBoundary;
double * maxOriginalBoundary;
double * minActualBoundary;
double * maxActualBoundary;
RHdrNd auxCellRTree;
int id;
};
struct GtreeData{
Region rgnRect; // pointer to rectangle incase of internal node
int groupElem;
};
struct GtreeNode{
NODETYPE ndType; //type of tree node (internal or external)
GTreeData tdInfo; //pointer to treedata structure
};
struct GhdrNd{ //node in data list
unsigned int uiCnt; // Number of elements in the list
GLstNd ptrFirstNd; // First node of the list
GLstNd ptrParentNd; // Parent node of the list
};
struct GlstNd{
//node of child list
GTreeNode tnInfo; // Data MBR Information is stored here.
GHdrNd ptrChildLst; // List of child nodes
GLstNd ptrNextNd; // Next node in the list
};
// the defs for R Tree
struct Rnb{
int n;
int Gindex;
double dist;
RNB nbNext;
};
struct RnbHdr{
int nbhCnt;
RNB nbFirst;
RNB nbLast;
};
struct RtreeData{
Region rgnRect; // pointer to rectangle incase of internal node
Data dataClstElem; //pointer to a Data in case of external node
};
struct RtreeNode{
NODETYPE ndType; //type of tree node (internal or external)
RTreeData tdInfo; //pointer to treedata structure
};
struct RhdrNd{ //node in data list
unsigned int uiCnt; // Number of elements in the list
RLstNd ptrFirstNd; // First node of the list
RLstNd ptrParentNd; // Parent node of the list
};
struct RlstNd{ //node of child list
RTreeNode tnInfo; // Data
RHdrNd ptrChildLst; // List of child nodes
RLstNd ptrNextNd; // Next node in the list
};
void dbscan(GHdrNd GRTree, DataHdr dataList, double epsilon, int min_pts);
int expandHelp(int index, int cluster_id, DataHdr dataList, double epsilon, int min_pts);
#endif