How does DBSCAN identify clusters using density?

Last updated 11 November 2026

DBSCAN defines a cluster as a maximal set of density-connected points. It marks points with dense neighborhoods as core points, grows clusters by chaining core points that lie within eps of each other, attaches nearby sparse points as border points, and leaves the rest as noise.

  • Two parameters define density:

    • eps: the neighborhood radius.

    • min_samples: the minimum number of points in that radius for a point to count as dense (core).

  • Key relations:

    • Directly density-reachable: q is in the eps-neighborhood of core point p.

    • Density-reachable: there is a chain of core points leading from p to q.

    • Density-connected: p and q are both reachable from some common core point. Clusters are built from this relation.

  • Algorithm:

    1. Pick an unvisited point and find its eps-neighbors.

    2. If it is not core, mark it noise for now. It may later become a border point.

    3. If it is core, start a new cluster and expand it breadth-first. Add all neighbors, and keep expanding through any neighbor that is itself core.

    4. Repeat until every point has been visited.

  • Consequences:

    • There is no k to set, clusters can take arbitrary shapes, and outliers are detected natively.

    • A single global density threshold means it struggles when clusters have very different densities.

    • Runtime is about O(n log n) with a spatial index and O(n²) in the worst case or in high dimensions.

  • https://scikit-learn.org/stable/modules/clustering.html
  • https://www.analyticsvidhya.com/blog/2021/05/20-questions-to-test-your-skills-on-dbscan-clustering-algorithm/
  • https://pwskills.com/blog/data-science/dbscan-clustering-in-ml
All Clustering interview questions