SAT_to_CLIQUE

SAT_to_CLIQUE - / Arup Guha / 7/25/2011 / / Example for COT...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
// Arup Guha // 7/25/2011 // Example for COT 4210 written in class. / import java.io.*; import java.util.*; i // Stores an instance of 3-SAT class sat { c public int numClauses; public int numVariables; public int[][] clauses; p // Assumes fin is reading from a file that describes // a 3-sat instance. public sat(Scanner fin) { p // Read in the number of clauses and variables. numClauses = fin.nextInt(); numVariables = fin.nextInt(); n // Read through each variable in each clause. clauses = new int[numClauses][3]; for (int i=0; i<numClauses; i++) for (int j=0; j<3; j++) clauses[i][j] = fin.nextInt(); c } // Returns true iff x and y have equal magnitude and have // opposite signs. public static boolean oppose(int x, int y) { return x+y == 0; } public clique reduce() { p // Make the graph the correct size. boolean[][] graph = new boolean[3*numClauses][3*numClauses]; b for (int i=0; i<graph.length; i++) { for (int j=i+1; j<graph.length; j++) { f // These two variables are in the same clause. if (i/3 == j/3) continue;
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 2

SAT_to_CLIQUE - / Arup Guha / 7/25/2011 / / Example for COT...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online