Hoshen–Kopelman algorithm: Difference between revisions

Content deleted Content added
The description of the Union operation (from the Union-Find algorithm) was factually incorrect. Also, the characterization of Union-Find as computing equivalence classes was also incorrect. I corrected the description of Union-Find, which is now aligned with the (correct) information on the Union-Find Algorithm page.
The pseudo-code given does not produce the example output, and in fact omits the final step of the algorithm. I noted this in the text, but have not modified the code.
Line 26:
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;