SUNIL GUTTA

SUNIL GUTTA

  • NA
  • 1k
  • 394.2k

java for loop fix ?

Feb 16 2014 9:13 PM
Hi
 

The four color theorem states that any map in a plane can be colored using four colors in such a way that regions sharing a common boundary do not share the same color. The task is to ask the user how many regions they have an express the regions into an adjacency matrix. Say 100 by 100 but probably won't have more then say 8 regions. Using four colors say Region A== Color red Region B == color blue Region C == color green Region D == color orange. Use an adjacency matrix to encode which region borders on which other region.

-------------------------------So my columns and rows of my matrix are my regions, while the cells should contain a 0 (zero) if the two regions are not adjacent. And a 1 (one) if they border one another. My solution will need a recursive backtracking solution which takes in an input from the user on the number of regions in the map and the filename of the adjacency matrix expressing the maps makeup.

I'm really lost on how to start here. I know I need to have something along int [][] adj; int num Regions; int [] colmns; System.out.print("Enter in the number of regions" + regions); // import the file from the user, // FROM here I assume loop the borders and figure out which are adjacent and which aren't , // from there assign a color to that region, // from that region determine the number of regions around it and assign them colors so that no same colors are touching one another, // then move on from there till the map is filled and no regions of the same color are touching//, //return the regions with their assigned color

If someone could help me here I would really appreciate it. Not to sure of my algorithm here in order to fo this. I was thinking maybe a for loop somehow to solve this something like

for (i=0; i<node.count; i++)
{
.... int node = (i + start.node+1) % node.count;
.... [test for uncolored with colored neighbors, etc.]
}

// coding in java- using emacs and terminal etc.

Any help would be highly appreciated.

Don't think the task at hand is super complicated, I'm just not that experienced in this.
Thank again for any future help.
 

Answers (1)