This is a pseudocode for DBSCAN from "".
And I have tried the pseudocode from the page. I prefer this.
ExpandCluster(SetOfPoints, Point, ClId, Eps, MinPts) : Boolean; seeds:=SetOfPoints.regionQuery(Point,Eps); IF seeds.sizeEmpty DO currentP := seeds.first(); result := SetOfPoints.regionQuery(currentP, Eps); IF result.size >= MinPts THEN FOR i FROM 1 TO result.size DO resultP := result.get(i); IF resultP.ClId IN {UNCLASSIFIED, NOISE} THEN IF resultP.ClId = UNCLASSIFIED THEN seeds.append(resultP); END IF; SetOfPoints.changeClId(resultP,ClId); END IF; // UNCLASSIFIED or NOISE END FOR; END IF; // result.size >= MinPts seeds.delete(currentP); END WHILE; // seeds <> Empty RETURN True; END IFEND; // ExpandClusterDBSCAN (SetOfPoints, Eps, MinPts)// SetOfPoints is UNCLASSIFIED ClusterId := nextId(NOISE); FOR i FROM 1 TO SetOfPoints.size DO Point := SetOfPoints.get(i); IF Point.ClId = UNCLASSIFIED THEN IF ExpandCluster(SetOfPoints, Point, ClusterId, Eps, MinPts) THEN ClusterId := nextId(ClusterId) END IF END IF END FOREND; // DBSCAN
This can cluster the data based on density(or distance) consider noise, it's no complicated to implement.
I see that the most important thing that to get good result is to get good eps and minpts. and if your data is complicate the distance of two data point have so much influence on the result.
Good luck.