So I have a matrix (n row by m column) and want to find the region with the most connected "1s". For example if I have the following matrix:
1 1 0 0
0 1 1 0
0 0 1 0
1 0 0 0
There are 2 regions of "1s" in the matrix.
1st region:
1 1
1 1
1
2nd region:
1
I would like to create an algorithm that will output the maximum = 5. I think this has something to do with Depth First Search but I only have base R and access to a few packages.