Reputation: 133
i have a bool matrix, i wanna find area(s) that fill of 1(true value). the area represent as polygon(clock wise).
can somebody give me an idea.
Upvotes: 0
Views: 179
Reputation: 6814
The union-find algorithm is an excellent approach to find connected sub-graphs (or regions in this case). It's also a linear complexity algorithm so it's basically as good as BFS :)
http://www.algorithmist.com/index.php/Union_Find
Upvotes: 0
Reputation: 578
You could use BFS search method to solve the problem, or Flood-Fill algorithm to solve the problem
Or so you can use DFS to solve this problem if you like to use recurve
Upvotes: 1