Struct dbscan::dbscan::DBSCAN [] [src]

pub struct DBSCAN<T> { /* fields omitted */ }

Implementation of the DBSCAN clustering algorithm.

Methods

impl<T> DBSCAN<T> where T: Default + Copy + PartialOrd
[src]

Creates a new DBSCAN instance.

Parameters

  • eps - The maximum distance between two points for them to be in the same neighborhood.
  • min_points - The minimal number of points in a neighborhood for a point to be considered as a core point.

Performs DBSCAN clustering from the given distance matrix.

Returns

Returns cluster labels for each point in the dataset. Noisy samples are set to None.

Examples

let mut dbscan = DBSCAN::new(1, 2);
let mut m = SymmetricMatrix::<i8>::new(5);
m.set(0, 1, 1);
m.set(0, 2, 9);
m.set(0, 3, 9);
m.set(0, 4, 9);
m.set(1, 2, 9);
m.set(1, 3, 9);
m.set(1, 4, 9);
m.set(2, 3, 1);
m.set(2, 4, 9);
m.set(3, 4, 9);

let clustering = dbscan.perform_clustering(&m);

assert_eq!(clustering[0], Some(0));
assert_eq!(clustering[1], Some(0));
assert_eq!(clustering[2], Some(1));
assert_eq!(clustering[3], Some(1));
assert_eq!(clustering[4], None);

In the above example, points 0 and 1 form a single cluster, points 2 and 3 form a different cluster, and point 4 does not belong any cluster (it is a noise point).

Trait Implementations

impl<T: Debug> Debug for DBSCAN<T>
[src]

Formats the value using the given formatter.