// // Given a graph with v vertices and e edges what are the degrees of // vertices such that the graph has no triangles and no squares? // See D.K Garnick, Y.H. Harris Kwong & F. Lazebnik "Extremal Graphs without Three-Cycles // or Four-Cycles". In particular Propositions 2.6 and 2.7 // // v = number of vertices // e = number of edges // d = minimum degree // D = maximum degree // f(v) = maximum number of edges in a graph with v vertices that has no triangle or square // // Proposition 2.5: v >= 1+D.d >= 1+d.d // Proposition 2.7: d >= e-f(v-1) // D >= ceiling(2.e/v) // // This CP takes on the command line arguments v, e and f(v-1) and enumerates all graphical degree sequences // import java.util.*; import static choco.Choco.*; import choco.cp.model.CPModel; import choco.cp.solver.CPSolver; import choco.kernel.model.Model; import choco.kernel.solver.Solver; import choco.kernel.model.variables.integer.IntegerVariable; import choco.kernel.solver.ContradictionException; public class ExtremalWithDegreeSequence { static int ceiling(int x,int y){ int z = x/y; if (x%y > 0) z = z + 1; return z; } // // ceiling(x/y) // static void swap(int i, int j, int[] x){ int temp = x[i]; x[i] = x[j]; x[j] = temp; } static void sort(int[] x){ Arrays.sort(x); int n = x.length; for (int i=0;i