Ejemplo n.º 1
0
 def test_non_symmetric_min_unsat(self):
     G = nx.complete_graph(4)
     T = nx.empty_graph(4)
     edges = list(combinations(G.nodes(),2))
     T.add_edges_from(edges[1:])
     F = SubgraphFormula(G,[T])
     self.assertUNSAT(F)
Ejemplo n.º 2
0
 def test_no_templates(self):
     """No templates graphs should generate an empty fomula
     """
     dimacs = """\
     p cnf 0 0
     """
     G = nx.complete_graph(4)
     F = SubgraphFormula(G,[])
     self.assertCnfEqualsDimacs(F,dimacs)
Ejemplo n.º 3
0
    def test_parameters(self):
        for base in range(2,5):
            for template in range(2,5):
                parameters = ["cnfgen","-q","subgraph",
                              "--complete", base,
                              "--completeT" , template]
                G = nx.complete_graph(base)
                T = nx.complete_graph(template)
                F = SubgraphFormula(G,[T])
                self.checkFormula(sys.stdin,F, parameters)

                parameters = ["cnfgen","-q","subgraph",
                              "--complete", base,
                              "--emptyT" , template]
                G = nx.complete_graph(base)
                T = nx.empty_graph(template)
                F = SubgraphFormula(G,[T])
                self.checkFormula(sys.stdin,F, parameters)
Ejemplo n.º 4
0
    def test_non_symmetric_input_right(self):
        """Symmetric encoding on non-symmetric graph

        The formula in this test uses the NON symmetric encoding for
        a non symmetric graph. This causes the formula to be
        satisfiable, as it should be.

        """
        G = readGraph(sio(example1),"simple",file_format="kthlist")
        T = readGraph(sio(example1alt),"simple",file_format="kthlist")
        F = SubgraphFormula(G,[T])
        self.assertSAT(F)
Ejemplo n.º 5
0
    def test_non_symmetric_input_wrong(self):
        """Symmetric encoding on non-symmetric graph

        The formula in this test uses the symmetric encoding for a non
        symmetric graph. This causes the formula to be unsatisfiable,
        even if it should be SAT.

        """
        G = readGraph(sio(example1),"simple",file_format="kthlist")
        T = readGraph(sio(example1alt),"simple",file_format="kthlist")
        F = SubgraphFormula(G,[T],symmetric=True) # This should cause the wrong answer
        self.assertUNSAT(F)
Ejemplo n.º 6
0
    def test_non_symmetric_clause_generator(self):
        """Check a tricky case in the implementation

        If the formula uses non symmetric encoding for the subset of
        vertices, then also the part of the formula about matching the
        edges requires non symmetric encoding.

        This checks that both parts are implemented correctly.
        """
        G = nx.complete_graph(4)
        T = nx.empty_graph(4)
        F = SubgraphFormula(G,[T])
        self.assertUNSAT(F)
Ejemplo n.º 7
0
 def test_symmetric_min_unsat(self):
     G = nx.empty_graph(4)
     G.add_edge(0,1)
     T = nx.empty_graph(4)
     F = SubgraphFormula(G,[T])
     self.assertUNSAT(F)