โ† Wiki Index / Computation & Algorithms / DBSCAN
๐Ÿ’ป Computation & Algorithms

DBSCAN

DBSCAN (Density-Based Spatial Clustering of Applications with Noise) is a non-parametric unsupervised clustering algorithm that groups points into maximally connected high-density regions of arbitrary shape while labeling isolated points in low-density regions as noise.

DBSCAN (Density-Based Spatial Clustering of Applications with Noise) is a foundational non-parametric clustering and outlier-detection algorithm in computation and algorithms, spatial data mining, and machine learning, introduced by Martin Ester, Hans-Peter Kriegel, Jรถrg Sander, and Xiaowei Xu in 1996. Unlike centroid-based methods such as k-means clustering, which partition every point into one of k convex Voronoi diagram cells and require specifying the number of clusters k in advance, DBSCAN defines clusters as maximal density-connected sets of points separated by lower-density background regions.

Because DBSCAN grows clusters transitively through local neighborhood graphs rather than optimizing a global parametric centroid objective, it simultaneously discovers non-convex, elongated, or ring-shaped structures, determines the number of clusters automatically from two local density thresholds, and classifies isolated observations in sparse regions as explicit noise (outliers). In 2014, DBSCAN received the ACM SIGKDD Test of Time Award for its lasting impact across geographic information systems (GIS), astronomical sky surveys, single-cell transcriptomics, and LiDAR point-cloud segmentation.

Core Definitions and Density-Connectivity Graph

Let X = {x1, x2, โ€ฆ, xn} be a dataset equipped with a distance metric d(p, q) (such as Euclidean distance, cosine distance, or Levenshtein distance). DBSCAN is governed by two hyperparameters: a neighborhood radius ฮต > 0 and a minimum point count MinPts โˆˆ โ„•. For every point p โˆˆ X, its closed ฮต-neighborhood is defined as:

Nฮต(p) = { q โˆˆ X : d(p, q) โ‰ค ฮต }.

Based on the cardinality |Nฮต(p)|, every point in X falls into one of three topological roles:

  1. Core point: A point p โˆˆ X is a core point if its ฮต-neighborhood contains at least MinPts points (including p itself): |Nฮต(p)| โ‰ฅ MinPts.
  2. Directly density-reachable & Border point: A point q is directly density-reachable from a point p if q โˆˆ Nฮต(p) and p is a core point. A non-core point b (with |Nฮต(b)| < MinPts) that lies inside Nฮต(p) of at least one core point p is called a border point.
  3. Noise (outlier) point: Any point z โˆˆ X that is neither a core point nor directly density-reachable from any core point is classified as noise.

Density-Reachability vs. Density-Connectivity

A point q is density-reachable from p if there exists a chain of points p1, p2, โ€ฆ, pm with p1 = p and pm = q such that each pi+1 is directly density-reachable from pi (meaning p1, โ€ฆ, pmโˆ’1 must all be core points). Because q may be a border point, density-reachability is transitive but asymmetric. To obtain a symmetric relation, two points p and q are defined as density-connected if there exists a core point o โˆˆ X from which both p and q are density-reachable. A DBSCAN cluster C โІ X is then defined as a non-empty subset satisfying both maximality (if p โˆˆ C and q is density-reachable from p, then q โˆˆ C) and connectivity (all pairs p, q โˆˆ C are density-connected).

Algorithmic Execution and Spatial Indexing Complexity

DBSCAN traverses X via breadth-first search over the core-point neighborhood graph:

  1. Iterate through each unvisited point p โˆˆ X and mark p as visited.
  2. Execute a range query to retrieve Nฮต(p). If |Nฮต(p)| < MinPts, provisionally label p as NOISE (note that p may later be claimed as a border point by an adjacent core point).
  3. If |Nฮต(p)| โ‰ฅ MinPts, create a new cluster C, add p to C, and initialize a seed queue Q โ† Nฮต(p) \ {p}.
  4. While Q is non-empty, pop a point q from Q: if q was previously labeled NOISE, relabel q as a border member of C; if q was unvisited, mark q visited, assign q to C, query Nฮต(q), and if |Nฮต(q)| โ‰ฅ MinPts append all unqueued members of Nฮต(q) to Q.

Because DBSCAN performs exactly one ฮต-range query per point p โˆˆ X, its total time complexity is n ร— Trange. Without a spatial index, scanning all n points per query takes O(n2) time. When low-dimensional coordinates (d โ‰ค 20) are indexed in an R*-tree, k-d tree, ball tree, or Delaunay triangulation neighborhood graph, average-case runtime drops to O(n log n) with O(n) memory.

Density / Partitioning MethodHandles Non-Convex ShapesHandles Varying Cluster DensitiesDeterminism on All PointsTypical Time Complexity
Standard DBSCANYesNo (single global ฮต)Core & noise deterministic; border order-dependentO(n log n) indexed; O(n2) dense
DBSCAN* (Core-Only)YesNo (single global ฮต)100% deterministic (borders treated as noise)O(n log n)
OPTICS (Ordering Points)YesYes (reachability dendrogram)Deterministic orderingO(n log n)
HDBSCAN (Hierarchical)YesYes (mutual reachability MST)Deterministic hierarchy stabilityO(n log n) to O(n2)
k-Means ClusteringNo (convex Voronoi only)PoorInitialization-dependentO(nkd) per step

Parameter Selection, Determinism, and Hierarchical Extensions (OPTICS & HDBSCAN)

Choosing MinPts and the k-Distance Knee Plot

Ester et al. and subsequent high-dimensional analyses (Schubert et al., 2017) recommend setting MinPts โ‰ฅ d + 1, with MinPts = 2d as a robust default for noisy datasets of dimension d (and MinPts = 4 for 2D spatial data). Once MinPts is fixed, the radius ฮต is selected by computing the distance dk(p) from each point p โˆˆ X to its (MinPts โˆ’ 1)-th nearest neighbor, sorting these distances in ascending order, and locating the "knee" or "elbow" where the sorted k-distance curve bends sharply upward from compact intra-cluster spacing to sparse background noise.

Border-Point Ambiguity, OPTICS, and HDBSCAN

Restricted to core points and noise points, DBSCAN is deterministic: core points form connected components of the undirected symmetric graph on {p : |Nฮต(p)| โ‰ฅ MinPts} with edges d(p, q) โ‰ค ฮต. Only border points within distance ฮต of two clusters can change membership depending on iteration order; DBSCAN* (Campello et al., 2013) eliminates this ambiguity by defining only core points as cluster members.

When a dataset contains clusters of varying densities, no single global radius ฮต resolves dense sub-clusters without splitting sparse clusters into noise. OPTICS (Ankerst et al., 1999) orders points by their core distance and reachability distance across all scales ฮต, while HDBSCAN (Campello, Moulavi, & Sander, 2013) builds the minimum spanning tree of the mutual reachability distance dmreach(p, q) = max{corek(p), corek(q), d(p, q)} and extracts persistent clusters using a single minimum-cluster-size hyperparameter.

Frequently Asked Questions

Why does DBSCAN setting MinPts = 2 reduce to single-linkage hierarchical clustering?

When MinPts = 2 (or MinPts = 1), every point with at least one neighbor within distance ฮต is a core point. The DBSCAN clusters then coincide with the connected components of the ฮต-neighborhood graph, which matches cutting a single-linkage hierarchical clustering dendrogram at height ฮต.

How does the curse of dimensionality affect DBSCAN?

In high-dimensional Euclidean spaces (d โ‰ซ 50), pairwise Euclidean distances concentrate around their mean (limdโ†’โˆž (dmax โˆ’ dmin)/dmin โ†’ 0), flattening density contrast. Applying principal component analysis or UMAP dimensionality reduction, or switching from Euclidean distance to cosine or shared-nearest-neighbor (SNN) similarity, restores density separation.

References

  1. Ester, M., Kriegel, H.-P., Sander, J., & Xu, X. (1996). A density-based algorithm for discovering clusters in large spatial databases with noise. Proceedings of the Second International Conference on Knowledge Discovery and Data Mining (KDD-96), 226โ€“231. https://doi.org/10.5555/3001460.3001507
  2. Ankerst, M., Breunig, M. M., Kriegel, H.-P., & Sander, J. (1999). OPTICS: Ordering points to identify the clustering structure. ACM SIGMOD Record, 28(2), 49โ€“60. https://doi.org/10.1145/304181.304187
  3. Campello, R. J. G. B., Moulavi, D., & Sander, J. (2013). Density-based clustering based on hierarchical density estimates. Advances in Knowledge Discovery and Data Mining (PAKDD 2013), 160โ€“172. https://doi.org/10.1007/978-3-642-37456-2_14
  4. Schubert, E., Sander, J., Ester, M., Kriegel, H. P., & Xu, X. (2017). DBSCAN revisited, revisited: Why and how you should (still) use DBSCAN. ACM Transactions on Database Systems, 42(3), 19:1โ€“19:21. https://doi.org/10.1145/3068335
๐Ÿงฌ Support Open Science
Explore interactive science games on LowKey Games or browse scientific apparel & accessories in the CRV Science Shop.
๐Ÿ’ก Spot an inaccuracy or have primary literature to expand this article?
Submit a citation or revision note using your shared CRV Science / LowKey Games profile ID.
Suggest Revision