Reducing eps if count > 5*minPts
Signed-off-by: James Ketrenos <james_gitlab@ketrenos.com>
This commit is contained in:
parent
026b0cf0a2
commit
f5c3c14257
@ -42,6 +42,7 @@ typedef struct Face {
|
||||
|
||||
typedef struct FaceLink {
|
||||
struct FaceLink *pNext;
|
||||
long double distance;
|
||||
Face *pFace;
|
||||
} FaceLink;
|
||||
|
||||
@ -145,6 +146,7 @@ FaceLink *RangeQuery(Face **ppFaces, long int faceCount, Face *pQ, double eps) {
|
||||
if (pQ->distances[i] > 0.0 && pQ->distances[i] <= eps) {
|
||||
FaceLink *pLink = malloc(sizeof(*pLink));
|
||||
memset(pLink, 0, sizeof(*pLink));
|
||||
pLink->distance = pQ->distances[i];
|
||||
pLink->pFace = pFace;
|
||||
pLink->pNext = pNeighbors;
|
||||
pNeighbors = pLink;
|
||||
@ -170,8 +172,6 @@ long int chainLength(FaceLink *pLink) {
|
||||
return count;
|
||||
}
|
||||
|
||||
long int maxPts = 0;
|
||||
|
||||
long int DBSCAN(Face **ppFaces, long int faceCount, double eps, int minPts) {
|
||||
long int C = 0;
|
||||
for (long int i = 0; i < faceCount; i++) {
|
||||
@ -184,18 +184,22 @@ long int DBSCAN(Face **ppFaces, long int faceCount, double eps, int minPts) {
|
||||
continue;
|
||||
}
|
||||
|
||||
double threshold = eps;
|
||||
FaceLink *pNeighbors = RangeQuery(ppFaces, faceCount, pFace, eps);
|
||||
long neighborCount = chainLength(pNeighbors);
|
||||
if (neighborCount > maxPts) {
|
||||
maxPts = neighborCount;
|
||||
fprintf(stderr, "New max with id %ld: %ld\n", pFace->faceId, maxPts);
|
||||
while (neighborCount > minPts * 5) {
|
||||
fprintf(stderr, "\nWith eps of %f, %ld has %ld neighbors.", threshold, pFace->faceId, neighborCount);
|
||||
threshold *= 0.9;
|
||||
freeChain(pNeighbors);
|
||||
pNeighbors = RangeQuery(ppFaces, faceCount, pFace, threshold);
|
||||
neighborCount = chainLength(pNeighbors);
|
||||
}
|
||||
|
||||
if (neighborCount < minPts) {
|
||||
pFace->clusterType = NOISE;
|
||||
freeChain(pNeighbors);
|
||||
continue;
|
||||
break;
|
||||
}
|
||||
|
||||
//printf("%ld has %ld neighbors.\n", pFace->faceId, neighborCount);
|
||||
|
||||
C++;
|
||||
@ -224,11 +228,15 @@ long int DBSCAN(Face **ppFaces, long int faceCount, double eps, int minPts) {
|
||||
|
||||
FaceLink *pSubNeighbors = RangeQuery(ppFaces, faceCount, pQ, eps);
|
||||
neighborCount = chainLength(pSubNeighbors);
|
||||
while (neighborCount > minPts * 5) {
|
||||
fprintf(stderr, "\nWith eps of %f, %ld has %ld neighbors.", threshold, pFace->faceId, neighborCount);
|
||||
threshold *= 0.9;
|
||||
freeChain(pNeighbors);
|
||||
pNeighbors = RangeQuery(ppFaces, faceCount, pFace, threshold);
|
||||
neighborCount = chainLength(pNeighbors);
|
||||
}
|
||||
|
||||
if (neighborCount >= minPts) {
|
||||
if (neighborCount > maxPts) {
|
||||
maxPts = neighborCount;
|
||||
fprintf(stderr, "New max with id %ld: %ld\n", pFace->faceId, maxPts);
|
||||
}
|
||||
pQ->clusterType = CORE;
|
||||
/* Append these neighbors to the end of the chain */
|
||||
FaceLink *pTmp = pLink;
|
||||
@ -376,7 +384,7 @@ int main(int argc, char *argv[]) {
|
||||
}
|
||||
|
||||
if (profileDistance <= 0.5) {
|
||||
fprintf(stderr, "Face id %ld distance from profile face: %Lf\n",
|
||||
fprintf(stderr, "\nFace id %ld distance from profile face: %Lf",
|
||||
ppFaces[processed]->faceId, profileDistance);
|
||||
/* This entry will be skipped */
|
||||
entries--;
|
||||
|
Loading…
x
Reference in New Issue
Block a user