Пример #1
0
    def test_maximum_independent_set_basic(self):
        """Runs the function on some small and simple graphs, just to make
        sure it works in basic functionality.
        """
        G = dnx.chimera_graph(1, 2, 2)
        clique = dnx.maximum_clique(G, dimod.ExactSolver())
        self.assertTrue(dnx.is_clique(G, clique))

        G = nx.path_graph(5)
        clique = dnx.maximum_clique(G, dimod.ExactSolver())
        self.assertTrue(dnx.is_clique(G, clique))
Пример #2
0
    def test_default_sampler(self):
        G = nx.complete_graph(5)
        dnx.set_default_sampler(dimod.ExactSolver())
        self.assertIsNot(dnx.get_default_sampler(), None)

        clique = dnx.maximum_clique(G)
        dnx.unset_default_sampler()
        self.assertEqual(dnx.get_default_sampler(), None, "sampler did not unset correctly")
Пример #3
0
 def test_two_cliques(self):
     # This graph has two major cliques [0,1,2,3,4] and [11,12,13,14]
     # but the first one is bigger so that's the maximum_clique.
     G = nx.complete_graph(5)
     nx.add_path(G, [4, 5, 6, 7, 8])
     nx.add_path(G, [2, 9, 10])
     nx.add_path(G, [9, 11])
     nx.add_path(G, [11, 12, 13, 14, 11])
     nx.add_path(G, [12, 14])
     nx.add_path(G, [13, 11])
     clique = dnx.maximum_clique(G, dimod.ExactSolver())
     self.assertEqual(clique, [0, 1, 2, 3, 4])