예제 #1
0
    def test_remove_inv_edges(self):
        graph = Graph()
        graph.add('A', 'isa', 'B')
        graph.add('A', 'p', 'C', inverted=True)

        self.assertEqual(2, graph.number_of_edges())

        graph.remove_inverse()

        self.assertEqual(1, graph.number_of_edges())
예제 #2
0
    def test_invert_edges(self):
        graph = Graph()
        graph.add('A', 'isa', 'B')

        self.assertEqual(1, graph.number_of_edges())

        graph.apply_inverse()

        self.assertEqual(2, graph.number_of_edges())
        self.assertTrue(graph.has_edge_with_attr('A', 'isa', 'B', Attribute.INV, False))
        self.assertTrue(graph.has_edge_with_attr('B', 'isa', 'A', Attribute.INV, True))
        self.assertTrue(graph.has_edge_with_attr('B', 'isa', 'A', Attribute.QTF, Quantifier.SOME))
예제 #3
0
    def test_has_edge(self):
        graph = Graph()
        graph.add('A', 'isa', 'B')
        graph.add('C', 'produce', 'D')

        self.assertTrue(graph.has_edge('A', 'isa', 'B'))
예제 #4
0
    def test_nodes(self):
        graph = Graph()
        graph.add('A', 'isa', 'B')

        self.assertIn("A", graph.nodes)
        self.assertIn("B", graph.nodes)
예제 #5
0
    def test_number_of_edges(self):
        graph = Graph()
        graph.add('A', 'isa', 'B')
        graph.add('C', 'produce', 'D')

        self.assertEqual(2, graph.number_of_edges())
예제 #6
0
    def test_number_of_nodes(self):
        graph = Graph()
        graph.add('A', 'isa', 'B')

        self.assertEqual(2, graph.number_of_nodes())
        self.assertEqual(1, graph.number_of_edges())