Finding islands in a grid? traversing a graph to find smaller disjoint set

  • Thread starter Thread starter farful
  • Start date Start date
  • Tags Tags
    Graph Grid Set
Click For Summary
SUMMARY

This discussion focuses on identifying "islands" of 1's in an nxn matrix using MATLAB. The proposed solution involves modifying pathfinding algorithms for 2D grids, specifically through nodal expansion. The algorithm begins with a source node, checking if it is connected to the border, and then expands to adjacent nodes. Nodes that are 1's and not connected to the border are classified as part of an island, which can then be eliminated.

PREREQUISITES
  • Understanding of MATLAB programming
  • Familiarity with graph traversal algorithms
  • Knowledge of 2D grid representations
  • Concept of node exploration and marking in algorithms
NEXT STEPS
  • Research "MATLAB graph traversal algorithms"
  • Learn about "nodal expansion techniques in pathfinding"
  • Explore "2D grid representation in MATLAB"
  • Study "marking explored nodes in search algorithms"
USEFUL FOR

Mathematics enthusiasts, MATLAB developers, and anyone interested in algorithm design for grid-based problems.

farful
Messages
55
Reaction score
1
I'm working in matlab, and looking for help on how to do the following. (answers in any language or pseudocode will be fine)

I have an nxn matrix, with each cell containing a 1 or a 0. The border cells are all 1's.

Is there an efficient algorithm to determine if there are any "islands" of 1's? That is, any 1's not connected to the border.

For example, if my matrix is:

1 1 1 1 1 1
1 0 0 0 1 1
1 0 1 0 0 1
1 0 1 1 0 1
1 0 0 0 0 1
1 1 1 1 1 1

I'd like to be able to identify the island of the three 1's (and eliminate them).

Thanks!
 
Technology news on Phys.org
How about nodal expansion? You can take the expansion part of pathfinder algorithms for 2D grids and modify it a bit. Choose a source node, if this node is connected to the border, then expand to another node, or several nodes. Choose the node which is not connected to the border as the source and expand to other nodes. If those nodes are 1s and not connected to the border, then you have your island (your current source and expanded nodes). Of course you will have to specify how many 1s make an island, and how these 1s relate to your current source node. You should mark explored nodes as already explored, since they cannot be used again. It will help your expansion algorithm.
 

Similar threads

Replies
9
Views
3K
Replies
2
Views
2K
Replies
2
Views
3K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
Replies
7
Views
2K
Replies
2
Views
3K
  • · Replies 7 ·
Replies
7
Views
3K
Replies
1
Views
2K