forked from ADAPTLab/MuDBSCAN
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathData.cpp
More file actions
202 lines (158 loc) · 5.28 KB
/
Data.cpp
File metadata and controls
202 lines (158 loc) · 5.28 KB
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
/*
Algorithm: Micro-cluster based DBSCAN
Author: Aditya Sarma
email: asaditya1195@gmail.com
*/
#include "Data.h"
#include "vectorc.h"
void unionFindMerge(DataHdr dataList, int root1, int root2, Data dataroot1, Data dataroot2)
{
// root1 = dataroot1->id;
// root2 = dataroot2->id;
int root;
while(dataroot1->parentId != dataroot2->parentId)
{
if(dataroot1->parentId < dataroot2->parentId)
{
// Find top most point of the tree that dataroot1 belongs to. Store that number in the variable root
if(dataroot1->parentId == root1)
{
dataroot1->parentId = dataroot2->parentId;
root = dataroot2->parentId;
break;
}
// splicing compression technique
int z = dataroot1->parentId;
dataroot1->parentId = dataroot2->parentId;
root1 = z;
dataroot1 = dataList->dataClstElem + root1;
}
else
{
if(dataroot2->parentId == root2)
{
dataroot2->parentId = dataroot1->parentId;
root = dataroot1->parentId;
break;
}
// splicing compressio technique
int z = dataroot2->parentId;
dataroot2->parentId = dataroot1->parentId;
root2 = z;
dataroot2 = dataList->dataClstElem + root2;
}
}
}
DataHdr initDataHdr(int size)
{
DataHdr dataHdrInfo = (DataHdr)calloc(1, sizeof(struct dataHdr));
// assert(dataHdrInfo != NULL);
dataHdrInfo->uiCnt = 0;
dataHdrInfo->localCnt = 0;
dataHdrInfo->dataClstElem=(Data)calloc(size, sizeof(struct data));
// assert(dataHdrInfo->dataClstElem!=NULL);
return dataHdrInfo;
}
void insertDataLstElemRemote(DataHdr dataHdrInfo, DataPoint iData, int parentId, int remoteIndex)
{
Data dataClstElem = dataHdrInfo->dataClstElem + dataHdrInfo->uiCnt;
dataClstElem->id = dataHdrInfo->uiCnt;
dataClstElem->iData = iData;
dataHdrInfo->uiCnt++;
dataClstElem->haloPoint = TRUE;
dataClstElem->childCount = 0;
dataClstElem->cid = -1;
dataClstElem->actualProcessId = parentId;
dataClstElem->remoteIndex = remoteIndex;
dataClstElem->parentId = remoteIndex;
dataClstElem->parentProcessId = parentId;
dataClstElem->isProcessed = TRUE;
dataClstElem->core_tag = FALSE;
dataClstElem->ClusterID = 0;
dataClstElem->group_id = -1;
return;
}
void populateDataListRemote(DataHdr dataList, vector< vector<double> >& remote_objects, vectorc* remote_PrIDs, vectorc* remote_Indices)
{
int i;
DataPoint iData;
// if(dataList->uiCnt != dataList->localCnt)
// {
// fprintf(stderr, "Unacceptable state! LocalCnt %d is supposed to be equal to total Count %d here!!\n", dataList->localCnt, dataList->uiCnt);
// exit(-1);
// }
for(i=0; i<remote_objects.size(); i++)
{
iData = (DataPoint) calloc(DIMENSION, sizeof(double));
// assert(iData != NULL);
int j;
for(j=0;j<DIMENSION;j++)
{
iData[j] = remote_objects[i][j];
}
insertDataLstElemRemote(dataList, iData, remote_PrIDs->intItems[i], remote_Indices->intItems[i]);
vector<double>().swap(remote_objects[i]);
}
vector< vector<double> >().swap(remote_objects);
}
void insertDataLstElemLocal(DataHdr dataHdrInfo, DataPoint iData, int rank)
{
Data dataClstElem = dataHdrInfo->dataClstElem + dataHdrInfo->uiCnt;
dataClstElem->id = dataHdrInfo->uiCnt; //ID represents local id. ID with respect to the local node
dataClstElem->iData = iData;
dataHdrInfo->uiCnt++;
dataHdrInfo->localCnt++;
dataClstElem->haloPoint = FALSE;
dataClstElem->remoteIndex = -1;
dataClstElem->actualProcessId = rank;
dataClstElem->childCount = 0;
dataClstElem->cid = -1;
dataClstElem->parentId = dataClstElem->id;
dataClstElem->parentProcessId = rank;
dataClstElem->isProcessed = FALSE;
dataClstElem->core_tag = FALSE;
dataClstElem->ClusterID = 0;
dataClstElem->group_id = -1;
return;
}
void populateDataListLocal(DataHdr dataList, vector< vector< double > >& objects)
{
int rank;
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
int i;
DataPoint iData;
// if(dataList->uiCnt != 0 || dataList->localCnt != 0)
// {
// fprintf(stderr, "Unacceptable state! dataList is supposed to empty here! LSize = %d TSize = %d\n", dataList->uiCnt, dataList->localCnt);
// exit(-1);
// }
for(i=0;i<objects.size();i++)
{
iData = (DataPoint) calloc(DIMENSION, sizeof(double));
// assert(iData != NULL);
int j;
for(j=0;j<DIMENSION;j++)
{
iData[j] = objects[i][j];
}
insertDataLstElemLocal(dataList, iData, rank);
vector<double>().swap(objects[i]);
}
vector< vector <double> >().swap(objects);
}
void printData(Data dataPoint)
{
printf("Group %d\t",dataPoint->group_id);
int iCnt=0;
for(iCnt = 0; iCnt < DIMENSION; iCnt++)
printf("%lf ", dataPoint->iData[iCnt] );
return;
}
void freeDataList(DataHdr dataList1)
{
int i;
for(i=0;i<dataList1->uiCnt;i++)
free((dataList1->dataClstElem+i)->iData);
free(dataList1->dataClstElem);
return;
}