Content deleted Content added
There is no reason for this link to go to specifically the page for ANNs when it is a generic network |
m Open access bot: url-access updated in citation with #oabot. |
||
(4 intermediate revisions by 2 users not shown) | |||
Line 1:
{{short description|Algorithm for labeling clusters on a grid}}
{{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 theory|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>{{Cite web |title=Union-Find Algorithms |url=https://www.cs.princeton.edu/~rs/AlgsDS07/01UnionFind.pdf
== Percolation theory ==
Line 12:
</gallery>||<gallery>
Occupied_Grids_P_%3D_0.64.png | {{center|'''Figure (b)'''}}
</gallery>|| Consider <code>5x5</code> grids in
|}
Line 19:
== Union-find algorithm ==
This algorithm is
== Pseudocode ==
During the [[raster scan]] of the grid, whenever an occupied cell is encountered, neighboring cells are scanned to check whether any of them have already been scanned. If we find already scanned neighbors, the <code>union</code> operation is performed, to specify that these neighboring cells are in fact members of the same
On the other hand, if the current cell has no neighbors, it is assigned a new, previously unused, label. The entire grid is processed in this way.
Following [[pseudocode]] 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 for cluster identification|first=Tobin |last=Fricke |website=ocf.berkeley.edu |date=2004-04-21 |access-date=2016-09-17}}</ref> On completion, the cluster labels may be found in <code>labels</code>. Not shown is the second raster scan of the grid needed to produce the example output. In that scan, the value at <code>label[x,y]</code> is replaced by <code>find(label[x,y])</code>.
'''Raster Scan and Labeling on the Grid'''
largest_label = 0;
Line 72 ⟶ 73:
== Example ==
Consider the following example. The dark cells in the grid in
The algorithm processes the input grid, cell by cell, as follows: Let's say that grid is a two-dimensional array.
Line 103 ⟶ 104:
|-
| <gallery>
H-K algorithm Input.png | {{center|'''Figure (
</gallery>||<gallery>
H-K algorithm output.png | {{center|'''Figure (
</gallery>|| Consider <code>6x6</code> grids in figure (
|}
|