Clusters are crowds. Points in a crowded area belong together, points alone in the dark are noise. No k to choose, and the clusters can be any shape.
1. Draw a circle2. Count the neighbours3. Grow the crowd
Big dot = core · small dot with ring = border · grey × = noise · hollow = not visited yet. Click to add, drag to move, double-click to remove. Hover to see the ε-circle. The circles are neighbourhoods used for counting, not cluster boundaries: a cluster is a chain of overlapping core neighbourhoods plus the border points they reach.
Clusters0
Noise0
Core pts0
Behind the scenes · 1
Count the neighbours
For every point, DBSCAN counts how many points (itself included) sit within distance ε. If that count reaches minPts, the point is a core point. A non-core point that lies within ε of a core point is a border point. Everything else is noise.
Table shows the first eight points with your current ε and minPts.
Behind the scenes · 2
Choosing ε: the k-distance graph
Each point’s distance to its (minPts − 1)-th nearest other point is plotted, sorted from largest to smallest. With minPts = 4 that is the third-nearest other point, because the point itself counts as one of the four neighbours. A point is core when this distance is at most ε. Drag the white line to set ε.
A sharp bend can suggest a useful ε: points above the line are non-core, points at or below it are core. Non-core points may be border points or noise, so inspect the resulting clusters before settling on ε.
Behind the scenes · 3
The algorithm
for each unvisited point p:
mark p visited
N = all points within ε of p (p included)
if |N| < minPts: label p noise (it may be rescued later)
else:
start a new cluster C, add p
for each q in N:
if q is noise: make it a border point of C
if q is unvisited:
mark visited, add to C
if q has ≥ minPts neighbours: add them to the queue
Use Step above to watch exactly this loop. Clusters only grow through core points; border points are absorbed but never spread the cluster further.
The mathematics
The mathematics behind DBSCAN
Numbers below update live with your data, ε and minPts.
A. The ε-neighbourhood
Nε(p) = { q ∈ D : d(p, q) ≤ ε }
B. Three kinds of point
core: |Nε(p)| ≥ minPts
Sits in a dense area. The engine of every cluster.
border: not core, but in Nε(core)
On the edge of a crowd. Belongs to a cluster but cannot extend it.
noise: neither
Too far from any dense region. Not assigned to any cluster.
C. Density-reachability
q is directly density-reachable from p
if q ∈ Nε(p) and p is a core point.
q is density-reachable from p
if there is a chain p = p1, ..., pn = q where each
pi+1 is directly reachable from pi.
A cluster is a maximal set of points that are
density-connected to each other.
Reading it
Chains of core points are how a cluster takes a curved shape.
Density-reachability is not always symmetric. A core point can reach nearby points, and chains of core points can extend a cluster.
A border point can be included in a cluster, but it cannot expand that cluster because it does not have enough neighbours of its own.
A border point within ε of core points from two different clusters is assigned to whichever cluster reaches it first.
D. Parameters and cost
Rules of thumb
These are starting points, not universal rules. A common start is minPts ≥ dimensions + 1; values around 2 × dimensions are also often tried. Higher values make the method less sensitive to small groups of nearby points, but the best setting depends on the dataset.
A knee in the k-distance graph is a heuristic for ε, not a guarantee.
One ε means one density scale, so clusters of very different density are hard.
Naive cost is O(n²); a spatial index can bring it near O(n log n) in low dimensions.
Experiment
Break it on purpose
Crescents
Load two interlocking moons. Centroid methods struggle here; density chains follow the curve.
ε far too small
Shrink the radius. Watch dense groups dissolve into noise and tiny fragments.
ε far too large
Grow the radius. Separate groups start to merge into one cluster.
Check yourself
Three quick questions
Key takeaways
Density defines a cluster: enough points packed within ε of each other.
Core, border, noise: every point gets one role, and noise is left unassigned rather than forced into a cluster.
No k needed, and clusters can take arbitrary shapes, but you must choose ε and minPts.
Scale matters: ε is a distance, so scale features sensibly when their units would distort it.
Limits: one ε struggles with clusters of very different density, and high dimensions make distances less informative.
Crafted with code in India. Array Blog documents the journey
of engineering—covering C++, Web, Machine Learning, and
Embedded Systems to help you build the future.