Content deleted Content added
added link |
HyperGaruda (talk | contribs) Inline external links are strongly discouraged per WP:ELPOINTS#2 |
||
Line 1:
{{Refimprove|date=September 2016}}
{{Machine learning bar}}
The '''Hoshen–Kopelman algorithm''' is a simple and efficient [[algorithm]] for labeling [[Cluster analysis|clusters]] on a grid. Where the grid is a regular [[network]] of cells,with the cells being either occupied or unoccupied. This algorithm is based on a well-known [[Disjoint-set data structure|union-finding algorithm]].<ref> https://www.cs.princeton.edu/~rs/AlgsDS07/01UnionFind.pdf </ref> The algorithm was originally described in by J. Hoshen and R. Kopelman in their 1976 paper
== Percolation theory ==
[[Percolation theory]] is the study of the behavior and [[statistics]] of [[Cluster|clusters]] on [[Lattice graph|lattices]]. Suppose we have a large square lattice where each cell can be occupied with the [[probability]]
<center>
{|
Line 16 ⟶ 17:
== Hoshen–Kopelman algorithm for cluster finding ==
In this algorithm
== Union-find algorithm ==
== Pseudo-code ==
Following
▲Following [[Pseudocode|pseudo-code]] is referred from [https://www.ocf.berkeley.edu/~fricke/ Tobin Fricke's] implementation of the same algorithm.<ref name=":0">{{cite web|url=https://www.ocf.berkeley.edu/~fricke/projects/hoshenkopelman/hoshenkopelman.html |title=The Hoshen-Kopelman Algorithm |website=Ocf.berkeley.edu |date=2004-04-21 |accessdate=2016-09-17}}</ref>
<strong>Raster Scan and Labeling on the Grid</strong>
largest_label = 0;
Line 47 ⟶ 45:
}
<strong>Union</strong>
void union(int x, int y) {
labels[find(x)] = find(y);
}
<strong>Find</strong>
int find(int x) {
Line 73:
* <code>grid[0][3]</code> is occupied so check cell to the left which is unoccupied so we increment the current label value and assign the label to the cell as <code>2</code>.
* <code>grid[0][4]</code>, <code>grid[0][5]</code> and <code>grid[1][0]</code> are unoccupied so they are not labeled.
* <code>grid[1][1]</code> is occupied so check cell to the left and above, both the cells are unoccupied so assign
* <code>grid[1][2]</code> is occupied so check cell to the left and above, only
* <code>grid[1][3]</code> is occupied so check cell to the left and above, both the cells are occupied, so merge the two clusters and assign the cluster label of
* <code>grid[1][4]</code> is occupied so check cell to the left and above, only
* <code>grid[1][5]</code> , <code>grid[2][0]</code> and <code>grid[2][1]</code> are unoccupied so they are not labeled.
* <code>grid[2][2]</code> is occupied so check cell to the left and above, only cell above is occupied so assign the label of
* <code>grid[2][3]</code> , <code>grid[2][4]</code> and <code>grid[2][5]</code> are unoccupied so they are not labeled.
* <code>grid[3][0]</code> is occupied so check cell above which is unoccupied so we increment the current label value and assign the label to the cell as <code>4</code>.
* <code>grid[3][1]</code> is occupied so check cell to the left and above, only
* <code>grid[3][2]</code> is unoccupied so it is not labeled.
* <code>grid[3][3]</code> is occupied so check cell to the left and above, both the cells are unoccupied so assign
* <code>grid[3][4]</code> is occupied so check cell to the left and above, only
* <code>grid[3][5]</code> , <code>grid[4][0]</code> and <code>grid[4][1]</code> are unoccupied so they are not labeled.
* <code>grid[4][2]</code> is occupied so check cell to the left and above, both the cells are unoccupied so assign
* <code>grid[4][3]</code> is occupied so check cell to the left and above, both, cell to the left and above are occupied so merge the two clusters and assign the cluster label of
* <code>grid[4][4]</code> is unoccupied so it is not labeled.
* <code>grid[4][5]</code> is occupied so check cell to the left and above, both the cells are unoccupied so assign
* <code>grid[5][0]</code> , <code>grid[5][1]</code> , <code>grid[5][2]</code> and <code>grid[5][3]</code> are unoccupied so they are not labeled.
* <code>grid[5][4]</code> is occupied so check cell to the left and above, both the cells are unoccupied so assign
* <code>grid[5][5]</code> is occupied so check cell to the left and above, both, cell to the left and above are occupied so merge the two clusters and assign the cluster label of
<center>
{|
Line 105:
== Applications ==
* Segmentation and Clustering of a
* Determination of Nodal Domain Area and Nodal Line Lengths
*
* Modeling of
==
* [[K-means clustering|K-means clustering algorithm]]
* [[Fuzzy clustering|Fuzzy clustering algorithm]]
* Gaussian (
== References ==
|