Skip to content

andrzejgorgon/hoshen-kopelman-algorithm-javascript

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Hoshen-Kopelman algorithm - JavaScript implementation

JavaSscript implementation of the Hoshen-Kopelman algorithm.

To create JavaScript implementation I was using pseudo code from this Wikipedia site.

Usage

If you would like to use the implementation, the code is inside of rasterAndLabel.js file. Function rasterAndLabel(grid)takes one argument, which is two dimensional array with equal length of arrays. Passed have to be filled with true or false values. True value indicates that the particular part is occupied. In results function returns array of the same size as argument array, however result array is filled with number. Each number indicates membership to a group.

Example:

Input array:

true false false true false false
false true true true true false
false false true false false false
true true false true true false
false false true true false true
false false false false true true

Result array:

1 2
2 2 2 2
2
4 4 5 5
5 5 7
7 7

About

JavaScript implementation of Hoshen-Kopelman algorithm

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published