Ejemplo n.º 1
0
 def test_MD(self):
     print("---MD---")
     for i in range(0, COUNT+1):
         G = Graph(eval(PREFIX+".V_"+str(i)), eval(PREFIX+".E_"+str(i)))
         base.print_graph_name(PREFIX, i)
         T, w = tdlib.minDegree_decomp(G)
         self.assertEqual(tdlib.is_valid_treedecomposition(G, T), True)
Ejemplo n.º 2
0
 def test_min_vertex_cover(self):
     print("---minVertexCover--")
     for i in range(0, COUNT+1):
         G = Graph(eval(PREFIX+".V_"+str(i)), eval(PREFIX+".E_"+str(i)))
         base.print_graph_name(PREFIX, i)
         T, w = tdlib.minDegree_decomp(G)
         S = tdlib.min_vertex_cover_with_treedecomposition(G, T, True, True)
Ejemplo n.º 3
0
    def test_max_clique(self):
        print("---max_clique---")

        max_vc = 0
        avg_vc = 0.0
        max_time = 0
        avg_time = 0.0

        for i in range(0, COUNT + 1):
            base.print_graph_name(PREFIX, i)
            G = Graph(eval(PREFIX + ".V_" + str(i)),
                      eval(PREFIX + ".E_" + str(i)))

            start = time.time()
            T, w = tdlib.minDegree_decomp(G)
            S = tdlib.max_clique_with_treedecomposition(G, T)
            end = time.time()

            t = end - start

            max_vc = len(S) if len(S) > max_vc else max_vc
            avg_vc += len(S)

            max_time = t if t > max_time else max_time
            avg_time += t

        avg_vc /= COUNT
        avg_time /= COUNT

        print("max clique: " + str(max_vc))
        print("avg clique: " + str(avg_vc))
        print("max time: " + str(max_time))
        print("avg time: " + str(avg_time))
Ejemplo n.º 4
0
 def test_MD(self):
     print("---MD---")
     for i in range(0, COUNT+1):
         base.print_graph_name(PREFIX, i)
         G = Graph(eval(PREFIX+".V_"+str(i)), eval(PREFIX+".E_"+str(i)))
         T, w = tdlib.minDegree_decomp(G)
         self.assertEqual(tdlib.is_valid_treedecomposition(G, T), True)
Ejemplo n.º 5
0
 def test_max_independent_set(self):
     print("---maxIndependentSet---")
     for i in range(0, COUNT+1):
         G = Graph(eval(PREFIX+".V_"+str(i)), eval(PREFIX+".E_"+str(i)))
         base.print_graph_name(PREFIX, i)
         T, w = tdlib.minDegree_decomp(G)
         S = tdlib.max_independent_set_with_treedecomposition(G, T)
Ejemplo n.º 6
0
    def test_9(self):
        print("---Dimacs58---")
        G = Graph(Dimacs.V_58, Dimacs.E_58)

        T, w = tdlib.minDegree_decomp(G)
        print("MD_width: " + str(w))

        tdlib.generic_elimination_search2(G, MAX_NODES, MAX_ORDERINGS)
Ejemplo n.º 7
0
 def test_max_independent_set(self):
     print("---maxIndependentSet---")
     for i in range(0, COUNT + 1):
         G = Graph(eval(PREFIX + ".V_" + str(i)),
                   eval(PREFIX + ".E_" + str(i)))
         base.print_graph_name(PREFIX, i)
         T, w = tdlib.minDegree_decomp(G)
         S = tdlib.max_independent_set_with_treedecomposition(G, T)
Ejemplo n.º 8
0
 def test_min_vertex_cover(self):
     print("---minVertexCover--")
     for i in range(0, COUNT + 1):
         G = Graph(eval(PREFIX + ".V_" + str(i)),
                   eval(PREFIX + ".E_" + str(i)))
         base.print_graph_name(PREFIX, i)
         T, w = tdlib.minDegree_decomp(G)
         S = tdlib.min_vertex_cover_with_treedecomposition(G, T, True, True)
Ejemplo n.º 9
0
    def test_conversion(self):
	print("---conversion---")
        for i in range(0, COUNT+1):
            base.print_graph_name(PREFIX, i)
            G = Graph(eval(PREFIX+".V_"+str(i)), eval(PREFIX+".E_"+str(i)))
            T1, w1 = tdlib.minDegree_decomp(G)
            O = tdlib.treedec_to_ordering(T1)
            T2, w2 = tdlib.ordering_to_treedec(G, O)
            self.assertEqual(w1, w2)
Ejemplo n.º 10
0
 def test_conversion(self):
     print("---conversion---")
     for i in range(0, COUNT+1):
         G = Graph(eval(PREFIX+".V_"+str(i)), eval(PREFIX+".E_"+str(i)))
         base.print_graph_name(PREFIX, i)
         T1, w1 = tdlib.minDegree_decomp(G)
         O = tdlib.treedec_to_ordering(T1)
         T2, w2 = tdlib.ordering_to_treedec(G, O)
         self.assertEqual(w1, w2)
Ejemplo n.º 11
0
    def test_min_coloring(self):
        print("---minColoring--")
        for i in range(0, COUNT + 1):
            if i == 999:  #huge graph
                continue

            G = Graph(eval(PREFIX + ".V_" + str(i)),
                      eval(PREFIX + ".E_" + str(i)))
            base.print_graph_name(PREFIX, i)
            T, w = tdlib.minDegree_decomp(G)
            S = tdlib.min_coloring_with_treedecomposition(G, T)
Ejemplo n.º 12
0
    def test_max_clique(self):
        print("---max_clique---")
        for i in range(0, COUNT + 1):
            if base.skip(PREFIX, i, lambda x, y: y > 2000):
                print("skip.. ")
                base.print_graph_name(PREFIX, i)
                continue

            base.print_graph_name(PREFIX, i)
            G = Graph(eval(PREFIX + ".V_" + str(i)),
                      eval(PREFIX + ".E_" + str(i)))
            T, w = tdlib.minDegree_decomp(G)
            S = tdlib.max_clique_with_treedecomposition(G, T)
Ejemplo n.º 13
0
    def test_min_vertex_cover(self):
        print("---vertex_cover---")
        for i in range(0, COUNT + 1):
            if base.skip(PREFIX, i, lambda x, y: y > 2000):
                print("skip.. ")
                base.print_graph_name(PREFIX, i)
                continue

            base.print_graph_name(PREFIX, i)
            G = Graph(eval(PREFIX + ".V_" + str(i)),
                      eval(PREFIX + ".E_" + str(i)))
            T, w = tdlib.minDegree_decomp(G)
            if w > 17:
                print("...tw > 17, skipping...")
                continue

            S = tdlib.min_vertex_cover_with_treedecomposition(G, T)
Ejemplo n.º 14
0
    def test_min_dominating_set(self):
        print("---dominating_set---")
        for i in range(0, COUNT + 1):
            if i == 91:
                continue

            if base.skip(PREFIX, i, lambda x, y: y > 2000):
                continue

            base.print_graph_name(PREFIX, i)
            G = Graph(eval(PREFIX + ".V_" + str(i)),
                      eval(PREFIX + ".E_" + str(i)))
            T, w = tdlib.minDegree_decomp(G)
            if w > 8:
                print("...tw > 8, skipping...")
                continue

            S = tdlib.min_dominating_set_with_treedecomposition(G, T)
Ejemplo n.º 15
0
    def test_min_vertex_cover(self):
        print("---vertex_cover---")
        for i in range(0, COUNT+1):
            if i == 91:
                 continue

            if base.skip(PREFIX, i, lambda x,y: y > 10000):
                continue

            base.print_graph_name(PREFIX, i)
            G = Graph(eval(PREFIX+".V_"+str(i)), eval(PREFIX+".E_"+str(i)))
            T, w = tdlib.minDegree_decomp(G)
            if w > 25:
                print("...tw > 25, skipping...")
                continue

            S = tdlib.min_vertex_cover_with_treedecomposition(G, T)
            print(str(S))
Ejemplo n.º 16
0
    def test_max_clique(self):
        print("---max_clique---")

        max_vc = 0
        avg_vc = 0.0
        max_time = 0
        avg_time = 0.0

        for n in [50,100,200,250,500]:
            for k in range(1, 16):
                for p in [.97, .95, .90, .80, .70]:
                    for c in range(5):
                        suffix = str(n) + '_' + str(k) + '_' + str(p).replace('.','') + '_' + str(c)

                        base.print_graph_name(PREFIX, suffix)
                        G = Graph(eval(PREFIX+".V_"+str(suffix)), eval(PREFIX+".E_"+str(suffix)))

                        start = time.time()
                        T, w = tdlib.minDegree_decomp(G)
                        S = tdlib.max_clique_with_treedecomposition(G, T)
                        end = time.time()

                        t = end-start

                        max_vc = len(S) if len(S) > max_vc else max_vc
                        avg_vc += len(S)

                        max_time = t if t > max_time else max_time
                        avg_time += t

        avg_vc /= COUNT
        avg_time /= COUNT

        print("max clique: " + str(max_vc))
        print("avg clique: " + str(avg_vc))
        print("max time: " + str(max_time))
        print("avg time: " + str(avg_time))
Ejemplo n.º 17
0
 def test_minDegree_decomp_6(self):
     G = Graph(V_Pappus, E_Pappus)
     T, w = tdlib.minDegree_decomp(G)
     self.assertEqual(tdlib.is_valid_treedecomposition(G, T), True)
     self.assertEqual(w, 6)
Ejemplo n.º 18
0
 def test_minDegree_decomp_4(self):
     G = Graph(V_Petersen_double, E_Petersen_double)
     T, w = tdlib.minDegree_decomp(G)
     self.assertEqual(tdlib.is_valid_treedecomposition(G, T), True)
     self.assertEqual(w, 5)  # could be 4?
Ejemplo n.º 19
0
 def test_minDegree_decomp_8(self):
     for i in range(0, 10):
         V, E = randomGNP(20, 0.2)
         G = Graph(V, E)
         T, w = tdlib.minDegree_decomp(G)
         self.assertEqual(tdlib.is_valid_treedecomposition(G, T), True)
Ejemplo n.º 20
0
 def test_minDegree_decomp_7(self):
     G = Graph(V_Grid_5_5, E_Grid_5_5)
     T, w = tdlib.minDegree_decomp(G)
     self.assertEqual(tdlib.is_valid_treedecomposition(G, T), True)
     self.assertEqual(w, 5)
Ejemplo n.º 21
0
 def test_minDegree_decomp_6(self):
     G = Graph(V_Pappus, E_Pappus)
     T, w = tdlib.minDegree_decomp(G)
     self.assertEqual(tdlib.is_valid_treedecomposition(G, T), True)
     self.assertEqual(w, 6)
Ejemplo n.º 22
0
 def test_minDegree_decomp_5(self):
     G = Graph(V_Wagner, E_Wagner)
     T, w = tdlib.minDegree_decomp(G)
     self.assertEqual(tdlib.is_valid_treedecomposition(G, T), True)
     self.assertEqual(w, 4)
Ejemplo n.º 23
0
 def test_minDegree_decomp_4(self):
     G = Graph(V_Petersen_double, E_Petersen_double)
     T, w = tdlib.minDegree_decomp(G)
     self.assertEqual(tdlib.is_valid_treedecomposition(G, T), True)
     self.assertEqual(w, 5) # could be 4?
Ejemplo n.º 24
0
 def test_minDegree_decomp_0(self):
     for V, E in cornercases:
         G = Graph(V, E)
         T, w = tdlib.minDegree_decomp(G)
         self.assertEqual(tdlib.is_valid_treedecomposition(G, T), True)
Ejemplo n.º 25
0
 def test_minDegree_decomp_5(self):
     G = Graph(V_Wagner, E_Wagner)
     T, w = tdlib.minDegree_decomp(G)
     self.assertEqual(tdlib.is_valid_treedecomposition(G, T), True)
     self.assertEqual(w, 4)
Ejemplo n.º 26
0
 def test_minDegree_decomp_8(self):
     for i in range(0, 10):
         V, E = randomGNP(20, 0.2)
         G = Graph(V, E)
         T, w = tdlib.minDegree_decomp(G)
         self.assertEqual(tdlib.is_valid_treedecomposition(G, T), True)
Ejemplo n.º 27
0
 def test_minDegree_decomp_7(self):
     G = Graph(V_Grid_5_5, E_Grid_5_5)
     T, w = tdlib.minDegree_decomp(G)
     self.assertEqual(tdlib.is_valid_treedecomposition(G, T), True)
     self.assertEqual(w, 5)
Ejemplo n.º 28
0
 def test_minDegree_decomp_0(self):
     for V, E in cornercases:
         G = Graph(V, E)
         T, w = tdlib.minDegree_decomp(G)
         self.assertEqual(tdlib.is_valid_treedecomposition(G, T), True)