Hoshen–Kopelman algorithm: Difference between revisions

Content deleted Content added
Ppprabhu (talk | contribs)
Ppprabhu (talk | contribs)
No edit summary
Line 18:
So in the raster scan of the grid in question, each time an occupied cell is encountered, a check is done to see whether this cell has any neighboring cells who have already been scanned. If so, first a '''''union''''' operation is performed, to specify that these neighboring cells are in fact members of the same equivalence class. Then a '''''find''''' operation is performed to find a representative member of that equivalence class with which to label the current cell. If, on the other hand, the current cell has no neighbors, it is assigned a new, previously unused, label. The entire grid is processed in this way. The grid can be raster-scanned a second time, performing only '''''find''''' operations at each cell, to re-label the cells with their final assignment of a representative element.
 
<div style="background-color:#f9f9f9;color:#641E16;left-padding-left:15px;font-family:courier">
largest_label = 0;