Ejemplo n.º 1
0
 def test_name_of_all_num_invariant(self):
     inv_num.InvariantNum()
     oper.GraphOperations()
     for inv in inv_num.InvariantNum().all:
         self.assertTrue(
             Helper.run('single_graph.g6', f'{inv.code}(G)==1', {}) >= 0)
         print(inv.name)
Ejemplo n.º 2
0
 def test_translate_code_to_code_literal(self):
     inv_num.InvariantNum()
     oper.GraphOperations()
     for inv in inv_num.InvariantNum().all:
         expression = f'{inv.code}(G)==1'
         expression_translated = f'{inv.code_literal}(G)==1'
         self.assertEqual(
             expression_translated,
             Equation.split_translate_expression(expression)[0])
Ejemplo n.º 3
0
 def test_all_invariants_with_trivial_graph(self):
     trivial = nx.trivial_graph()
     for inv in inv_num.InvariantNum().all:
         self.assertTrue(
             isinstance(inv.calculate(trivial),
                        (float, int, numpy.int32, numpy.int64)))
     for inv in inv_bool.InvariantBool().all:
         self.assertTrue(isinstance(inv.calculate(trivial), bool))
     for inv in inv_other.InvariantOther().all:
         self.assertTrue(
             isinstance(inv.calculate(trivial),
                        (numpy.ndarray, list, tuple, dict, str, set)))
     for op in oper.GraphOperations().all:
         self.assertTrue(isinstance(op.calculate(trivial), nx.Graph))
Ejemplo n.º 4
0
 def test_all_invariants_with_disconnected_graph(self):
     # NOTE: disconnected graph with isolate vertice
     discon_graph = nx.from_graph6_bytes('J????OC?wF_'.encode('utf-8'))
     for inv in inv_num.InvariantNum().all:
         self.assertTrue(
             isinstance(inv.calculate(discon_graph),
                        (float, int, numpy.int32, numpy.int64)))
     for inv in inv_bool.InvariantBool().all:
         self.assertTrue(isinstance(inv.calculate(discon_graph), bool))
     for inv in inv_other.InvariantOther().all:
         self.assertTrue(
             isinstance(inv.calculate(discon_graph),
                        (numpy.ndarray, list, tuple, dict, str, set)))
     for op in oper.GraphOperations().all:
         self.assertTrue(isinstance(op.calculate(discon_graph), nx.Graph))
Ejemplo n.º 5
0
    def test_all_operations(self):
        for opg in oper.GraphOperations().all:
            for opm in oper.MathOperations().all:
                for inv in inv_num.InvariantNum().all:
                    print(f'{opm.name}-{str(inv.name)}-{str(opg.name)}')
                    self.assertTrue(
                        Helper.run(
                            'single_graph.g6',
                            f'{str(opm.code)}({str(inv.code)}({str(opg.code)}(G)))>0',
                            {}) >= 0)

                    self.assertEqual(
                        "",
                        Equation.validate_expression(
                            f'{str(opm.code)}({str(inv.code)}({str(opg.code)}(G)))>0'
                        ))