How to find all clusters of forest on map?

Posted by Damir on Stack Overflow See other posts from Stack Overflow or by Damir
Published on 2012-10-01T21:12:26Z Indexed on 2012/10/01 21:37 UTC
Read the original article Hit count: 247

Filed under:
|
|
|

How to find all clusters of forest on map ? I have simple class cell like (Type is enum {RIVER, FOREST,GRASS,HILL}

class Cell{
   public:
     Type type;
     int x;
     int y
};

and map like vector<Cell> grid. Can anyone suggest me algorithm to create list<list<Cell>> clusters where list contains FOREST cells in same cluster (cluster are set of connected cells - connection can be in eight direction:up,down,left,right,up_right,up_left,down_left,down_right)? I need to find all clusters of forest on map and put every single cluster in list<Cell>.

© Stack Overflow or respective owner

Related posts about c++

Related posts about algorithm