Find connection from one side to other
I have a 2D array (as in the image) and I need to find if the left side is connected to the right side.
I've created an object for each "1" with four boolean fields (up, right, down, left), indicating if there is a connection to the next "1".
I've read something about breadth first search, but I don't know how to implement it. Any pointers or help would be appreciated.
Re: Find connection from one side to other
Define "connected" in terms that make sense looking at the graphic you posted. If there's a connected path in the graphic, describe it or draw it.
Show the class you created that represents each "1". Rather than boolean fields to indicate if there's a connection to an adjacent neighbor, you may want to use a pointer to the adjacent neighbor if a connection exists, null if a connection does not exist. Using that approach, a path through the field of "1"s might be similar to data structures you're already familiar with or a tree of some kind.