Density-Based Spatial Clustering of Applications with Noise (DBSCAN)-VBForums

Thread: Density-Based Spatial Clustering of Applications with Noise (DBSCAN)

1. Density-Based Spatial Clustering of Applications with Noise (DBSCAN)

Originally Posted by wikipedia
Density-based spatial clustering of applications with noise (DBSCAN) is a data clustering algorithm. It is a density-based clustering algorithm because it finds a number of clusters starting from the estimated density distribution of corresponding nodes. DBSCAN is one of the most common clustering algorithms.

http://en.wikipedia.org/wiki/DBSCAN
How to use:

2. Add Dbscan.txt to your project, set the Copy to Output Directory property to Copy always on it.
3. Add a chart (from the System.Windows.Forms.DataVisualization namespace) to the form.

Code:
```public partial class Form1 : Form
{

#region fields

private static Color[] ChartColors = new Color[] { Color.FromArgb(0x41, 140, 240),   Color.FromArgb(0xfc, 180, 0x41),
Color.FromArgb(0xe0, 0x40, 10),   Color.FromArgb(5, 100, 0x92),
Color.FromArgb(0xbf, 0xbf, 0xbf), Color.FromArgb(0x1a, 0x3b, 0x69),
Color.FromArgb(0xff, 0xe3, 130),  Color.FromArgb(0x12, 0x9c, 0xdd),
Color.FromArgb(0xca, 0x6b, 0x4b), Color.FromArgb(0, 0x5c, 0xdb),
Color.FromArgb(0xf3, 210, 0x88),  Color.FromArgb(80, 0x63, 0x81),
Color.FromArgb(0xf1, 0xb9, 0xa8), Color.FromArgb(0xe0, 0x83, 10),
Color.FromArgb(120, 0x93, 190) };

#endregion

#region constructors

public Form1()
{
this.InitializeComponent();
this.InitializeChart();
}

#endregion

#region methods

private void InitializeChart()
{
Series series = this.chart1.Series[0];

series.ChartType = SeriesChartType.Point;
series.MarkerStyle = MarkerStyle.Circle;
series.MarkerSize = 10;

this.chart1.Legends[0].Enabled = false;

this.chart1.ChartAreas[0].AxisX.LabelStyle.Format = "N3";
this.chart1.ChartAreas[0].AxisX.MajorGrid.Enabled = false;

this.chart1.ChartAreas[0].AxisY.LabelStyle.Format = "N3";
this.chart1.ChartAreas[0].AxisY.MajorGrid.Enabled = false;
}

{

// generate chart based on Dbscan.txt
this.GenerateClusters();
}

private void GenerateClusters()
{

List<DbscanPoint> points = new List<DbscanPoint>();

// change path as appropriate

foreach (var line in lines)
{
var split = line.Split(' ');

Convert.ToDouble(split[2])));
}

// customize the epsilion radius and minimum cluster points here
// note: if you are using http://people.cs.nctu.edu.tw/~rsliang/dbscan/testdatagen.html
//       to generate data, make sure these parameters match the parameters on the site
//       otherwise you will get different results
DbscanAlgorithm.Dbscan(points.ToArray(), 4d, 6);

var series = this.chart1.Series[0];

foreach (var item in points)
{

if (item.IsNoise)
p.Color = SystemColors.Control;
else
p.Color = Form1.ChartColors[(item.ClusterId.Value - 1) % Form1.ChartColors.Length];
}
}

#endregion

}```
You should see this if everything was successful:

Here's how you can generate test data (this is what I verified the algorithm against): http://people.cs.nctu.edu.tw/~rslian...stdatagen.html.

Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•

Featured