smira / go-point-clustering

(Lat, lon) points fast clustering using DBScan algorithm
Other
50 stars 14 forks source link

Duplicate point in noise & cluster #9

Open rugleb opened 1 week ago

rugleb commented 1 week ago

Is it correct to add the point to the noise at this step?

        if len(neighborPts) < minPoints {
            noise = append(noise, i)
        }

As far as I understand, there may be a situation where a point from the noise will be added to the cluster later. Thus, the total number of points in clusters + noise will be greater than the total number of points.

rugleb commented 1 week ago

I think correct way like this:

    if len(neighborPts) < minPoints {
            continue
    }

    // expand cluster
        //...

Then after main cycle:

        for for i := 0; i < len(points); i++ {
            // build clusters
        }

    for i, member := range members {
        if !member {
            noise = append(noise, i)
        }
    }
smira commented 1 week ago

The algorithm is described in the comments above, if you feel the implementation is wrong, or the algorithm is wrong, please feel free to open a PR with some tests showing corrected behavior.