private static boolean checkConstraints(int nodes, int n) { int neighbours[] = g.getNeighbours(n); for (int j = 0; j < neighbours.length; j++) { if (neighbours[j] == 1) { if (colorOfNode[n] == colorOfNode[j]) return false; } } pruneTheDomain(nodes); return true; }
private static void pruneTheDomain(int nodes) { for (int i = 0; i < nodes; i++) { if (colorOfNode[i] != 0) { int neighbours[] = g.getNeighbours(i); for (int j = 0; j < neighbours.length; j++) { if (neighbours[j] == 1) { for (int k = 0; k < noOfColors; k++) { if (domainOfNode[j][k] == colorOfNode[i]) { domainOfNode[j][k] = 0; } } } } } } }
private static boolean checkEverything(int nodes) { for (int i = 0; i < nodes; i++) { if (colorOfNode[i] != 0) { int neighbours[] = g.getNeighbours(i); for (int j = 0; j < neighbours.length; j++) { if (neighbours[j] == 1) { if (colorOfNode[i] == colorOfNode[j]) { // System.out.println("color is same " + i + " " + j); return false; } } } } else { // System.out.println("no color"); return false; } } return true; }