import java.util.*; import java.io.*; public class GCol { int n, colours; long nodes, checks; boolean[][] adjacent; int[] v; // v[i] is value assigned to the vertex v[i] boolean trace; GCol(String fname) throws IOException { Scanner sc = new Scanner(new File(fname)); n = sc.nextInt(); adjacent = new boolean[n][n]; v = new int[n]; while (sc.hasNext()){ int i = sc.nextInt() - 1; int j = sc.nextInt() - 1; adjacent[i][j] = adjacent[j][i] = true; } sc.close(); } boolean consistent(int i,int j){ if (!adjacent[i][j]) return true; checks++; if (trace) System.out.println("check(v["+ (i+1) +"]="+ v[i] +",v["+ (j+1) +"]="+ v[j] +") -> "+ (v[i] != v[j])); return v[i] != v[j]; } // // If adjacent, is v[i] consistent with v[j]? // boolean solve(){ return expand(0); } boolean expand(int i){ if (trace){ System.out.print("expand("+ (i+1) +"): "); for (int j=0;j 2; if (gcol.solve()){ System.out.print("sol: "); for (int i=0;i