The DBSCAN Clustering Algorithm

The DBSCAN Clustering Algorithm

Gagarine Yaikhom/gyaikhom/dbscan
https://github.com/gyaikhom
https://github.com/gyaikhom/dbscan

In this project, we implement the DBSCAN clustering algorithm. For further details, please visit my homepage (implementing-the-dbscan-clustering-algorithm), or view the NOWEB generated documentation dbscan.pdf.


noweb is a literate programming tool, created in 1989–1999 by Norman Ramsey, and designed to be simple, easily extensible and language independent.


independent [,ɪndɪ'pendənt]:adj. 独立的,单独的,无党派的,不受约束的 n. 独立自主者,无党派者
extensible [ek'stensɪbl; ɪk'stensɪb(ə)l]:adj. 可延长的,可扩张的
literate ['lɪt(ə)rət]:adj. 受过教育的,精通文学的 n. 学者

Source code

This repository contains the following source code and data files:

  • dbscan.c - A C programming language implementation (uses 3D data points).
  • dbscan.js- A JavaScript implementation (uses 2D data points).
  • dbscan.min.js- A minified JavaScript implementation.
  • example.dat - Example data file.
  • imageseg - Adaptation of DBSCAN algorithm for image segmentation.
minify ['mɪnɪfaɪ]:vt. 使变小,贬低
adaptation [ædəp'teɪʃ(ə)n]:n. 适应,改编,改编本,改写本
segmentation [,seɡmən'teɪʃən]:n. 分割,割断,细胞分裂
supply [sə'plaɪ]:n. 供给,补给,供应品 vt. 供给,提供,补充 vi. 供给,替代

Usage

To run the algorithm on the supplied example data, first compile

$ clang -O2 -Wall -g -o dbscan dbscan.c -lm

and then run the program:

$ cat example.dat | ./dbscan

This will produce output as follows:

Epsilon: 1.000000
Minimum points: 2
Number of points: 53
x     y     z     cluster_id
----------------------------------------------
1.00  3.00  1.00: 0
1.00  4.00  1.00: 0
1.00  5.00  1.00: 0
1.00  6.00  1.00: 0
2.00  2.00  1.00: 2
2.00  3.00  0.00: 1
2.00  4.00  0.00: 1
2.00  5.00  0.00: 1
2.00  6.00  0.00: 1
2.00  7.00  1.00: 3
3.00  1.00  1.00: 2
3.00  2.00  1.00: 2
...

If you wish to try the algorithm interactively, a JavaScript implementation is available here (implementing-the-dbscan-clustering-algorithm). This
example uses HTML5 canvas and was implemented using d3js for DOM manipulation and user interaction.

usage ['juːsɪdʒ]:n. 使用,用法,惯例
epsilon ['epsɪlɒn; ep'saɪlɒn]:n. 希腊语字母之第五字
interactively:adv. 交互式地,互勤地
canvas ['kænvəs]:n. 帆布 vt. 用帆布覆盖,用帆布装备 adj. 帆布制的
manipulation [mə,nɪpjʊ'leɪʃ(ə)n]:n. 操纵,操作,处理,篡改
interaction [ɪntər'ækʃ(ə)n]:n. 相互作用,交互作用 n. 互动
Document Object Model,DOM:文件物件模型
markup ['mɑːkʌp]:n. 涨价,利润,审定
pattern ['pæt(ə)n]:n. 模式,图案,样品 vt. 模仿,以图案装饰 vi. 形成图案

HTML 5 (HTML5) is a software solution stack that defines the properties and behaviors of web page content by implementing a markup based pattern to it.

D3.js (just D3 for Data-Driven Documents) is a JavaScript library for producing dynamic, interactive data visualizations in web browsers.

Clang /ˈklæŋ/ is a compiler front end for the C, C++, Objective-C and Objective-C++ programming languages, as well as the OpenMP, OpenCL, RenderScript and CUDA frameworks.


strong@foreverstrong:~/dbscan_work$ pwd
/home/strong/dbscan_work
strong@foreverstrong:~/dbscan_work$ 
strong@foreverstrong:~/dbscan_work$ git clone https://github.com/gyaikhom/dbscan.git
Cloning into 'dbscan'...
remote: Enumerating objects: 41, done.
remote: Total 41 (delta 0), reused 0 (delta 0), pack-reused 41
Unpacking objects: 100% (41/41), done.
Checking connectivity... done.
strong@foreverstrong:~/dbscan_work$ 
strong@foreverstrong:~/dbscan_work$ cd dbscan/
strong@foreverstrong:~/dbscan_work/dbscan$ ll
total 176
drwxrwxr-x 4 strong strong   4096 Feb 12 10:26 ./
drwxrwxr-x 3 strong strong   4096 Feb 12 10:26 ../
-rw-rw-r-- 1 strong strong   8207 Feb 12 10:26 dbscan.c
-rw-rw-r-- 1 strong strong   2961 Feb 12 10:26 dbscan.js
-rw-rw-r-- 1 strong strong   1023 Feb 12 10:26 dbscan.min.js
-rw-rw-r-- 1 strong strong 128409 Feb 12 10:26 dbscan.pdf
-rw-rw-r-- 1 strong strong    643 Feb 12 10:26 example.dat
drwxrwxr-x 8 strong strong   4096 Feb 12 10:26 .git/
drwxrwxr-x 2 strong strong   4096 Feb 12 10:26 imageseg/
-rw-rw-r-- 1 strong strong   1084 Feb 12 10:26 LICENSE
-rw-rw-r-- 1 strong strong   1652 Feb 12 10:26 README.md
strong@foreverstrong:~/dbscan_work/dbscan$ 


strong@foreverstrong:~/dbscan_work/dbscan$ clang -O2 -Wall -g -o dbscan dbscan.c -lm
strong@foreverstrong:~/dbscan_work/dbscan$ 
strong@foreverstrong:~/dbscan_work/dbscan$ ll
total 204
drwxrwxr-x 4 strong strong   4096 Feb 12 11:58 ./
drwxrwxr-x 3 strong strong   4096 Feb 12 10:26 ../
-rwxrwxr-x 1 strong strong  25000 Feb 12 11:58 dbscan*
-rw-rw-r-- 1 strong strong   8207 Feb 12 10:26 dbscan.c
-rw-rw-r-- 1 strong strong   2961 Feb 12 10:26 dbscan.js
-rw-rw-r-- 1 strong strong   1023 Feb 12 10:26 dbscan.min.js
-rw-rw-r-- 1 strong strong 128409 Feb 12 10:26 dbscan.pdf
-rw-rw-r-- 1 strong strong    643 Feb 12 10:26 example.dat
drwxrwxr-x 8 strong strong   4096 Feb 12 10:26 .git/
drwxrwxr-x 2 strong strong   4096 Feb 12 10:26 imageseg/
-rw-rw-r-- 1 strong strong   1084 Feb 12 10:26 LICENSE
-rw-rw-r-- 1 strong strong   1652 Feb 12 10:26 README.md
strong@foreverstrong:~/dbscan_work/dbscan$ 


strong@foreverstrong:~/dbscan_work/dbscan$ cat example.dat | ./dbscan
Epsilon: 1.000000
Minimum points: 2
Number of points: 53
 x     y     z     cluster_id
-----------------------------
 1.00  3.00  1.00: 0
 1.00  4.00  1.00: 0
 1.00  5.00  1.00: 0
 1.00  6.00  1.00: 0
 2.00  2.00  1.00: 2
 2.00  3.00  0.00: 1
 2.00  4.00  0.00: 1
 2.00  5.00  0.00: 1
 2.00  6.00  0.00: 1
 2.00  7.00  1.00: 3
 3.00  1.00  1.00: 2
 3.00  2.00  1.00: 2
 3.00  3.00  1.00: 2
 3.00  4.00  0.00: 1
 3.00  5.00  0.00: 1
 3.00  6.00  1.00: 3
 3.00  7.00  1.00: 3
 4.00  1.00  1.00: 2
 4.00  2.00  1.00: 2
 4.00  3.00  0.00: 1
 4.00  4.00  0.00: 1
 4.00  5.00  1.00: -2
 4.00  6.00  0.00: 1
 4.00  7.00  1.00: 3
 4.00  8.00  1.00: 3
 5.00  1.00  1.00: 2
 5.00  2.00  0.00: 1
 5.00  3.00  0.00: 1
 5.00  4.00  0.00: 1
 5.00  5.00  0.00: 1
 5.00  6.00  0.00: 1
 5.00  7.00  1.00: 3
 5.00  8.00  1.00: 3
 6.00  1.00  1.00: 2
 6.00  2.00  0.00: 1
 6.00  3.00  1.00: 3
 6.00  4.00  1.00: 3
 6.00  5.00  1.00: 3
 6.00  6.00  1.00: 3
 6.00  7.00  1.00: 3
 7.00  1.00  1.00: 2
 7.00  2.00  0.00: 1
 7.00  3.00  0.00: 1
 7.00  4.00  0.00: 1
 7.00  5.00  1.00: 3
 8.00  1.00  1.00: 2
 8.00  2.00  1.00: 2
 8.00  3.00  0.00: 1
 8.00  4.00  1.00: 3
 8.00  5.00  1.00: 3
 8.00  6.00  1.00: 3
 9.00  2.00  1.00: 2
 9.00  3.00  1.00: 2
strong@foreverstrong:~/dbscan_work/dbscan$
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Yongqiang Cheng

梦想不是浮躁,而是沉淀和积累。

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值