Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 12111

Number of isolated clusters of two connected '1's (surrounded only by '0's or edges)

$
0
0

How can i make a program in python that calculates the number of isolated clusters of two connected '1' in a matrix containing only ones and zeroes?

I tried to verify the neighbors of each 1 but then it counts a cluster multiple times. Is there any way to do it without checking the neighbors at all?


Viewing all articles
Browse latest Browse all 12111

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>