Ejemplo n.º 1
0
 def cnf_from_variables_and_clauses(variables, clauses) :
     cnf = CNF()
     for variable in variables :
         cnf.add_variable(variable)
     for clause in clauses :
         cnf.add_clause(clause)
     return cnf
Ejemplo n.º 2
0
 def cnf_from_variables_and_clauses(variables, clauses):
     cnf = CNF()
     for variable in variables:
         cnf.add_variable(variable)
     for clause in clauses:
         cnf.add_clause(clause)
     return cnf
Ejemplo n.º 3
0
 def test_single_vertex_graph(self):
     """Singleton graph has no nontrivial automorphism."""
     G1=nx.Graph()
     G1.add_node(0)
     cnf1 = GraphAutomorphism(G1)
     v = list(cnf1.variables())[0]
     cnf2 = CNF()
     cnf2.add_clause([(True,v)])
     cnf2.add_clause([(False,v)])
     self.assertCnfEqual(cnf1,cnf2)
Ejemplo n.º 4
0
 def test_single_vertex_graph(self):
     """Singleton graph has no nontrivial automorphism."""
     G1 = nx.Graph()
     G1.add_node(0)
     cnf1 = GraphAutomorphism(G1)
     v = list(cnf1.variables())[0]
     cnf2 = CNF()
     cnf2.add_clause([(True, v)])
     cnf2.add_clause([(False, v)])
     self.assertCnfEqual(cnf1, cnf2)
Ejemplo n.º 5
0
 def test_one_clause(self):
     dimacs = """\
     p cnf 4 1
     1 2 -3 -4 0
     """
     opb = """\
     * #variable= 4 #constraint= 1
     *
     +1 x1 +1 x2 -1 x3 -1 x4 >= -1;
     """
     F = CNF()
     F.add_clause([(True, "a"), (True, "b"), (False, "c"), (False, "d")])
     F = Expand(F)
     self.assertCnfEqualsDimacs(F, dimacs)
     self.assertCnfEqualsOPB(F, opb)
Ejemplo n.º 6
0
 def test_one_clause(self) :
     dimacs="""\
     p cnf 4 1
     1 2 -3 -4 0
     """
     opb="""\
     * #variable= 4 #constraint= 1
     *
     +1 x1 +1 x2 -1 x3 -1 x4 >= -1;
     """
     F=CNF()
     F.add_clause([(True,"a"),(True,"b"),(False,"c"),(False,"d")])
     F = Expand(F)
     self.assertCnfEqualsDimacs(F,dimacs)
     self.assertCnfEqualsOPB(F,opb)