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())
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))
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'))
def test_nodes(self): graph = Graph() graph.add('A', 'isa', 'B') self.assertIn("A", graph.nodes) self.assertIn("B", graph.nodes)
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())
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())