Exemplo n.º 1
0
    def test_no_quant_pred_var(self):
        iG = nx.DiGraph()
        iG.add_nodes_from([(i, {'label': s}) for i, s in enumerate('Px')])
        iG.add_edges_from([(0, 1)])
        iG.graph['head_node'] = 0

        eG = nx.DiGraph()
        eG.add_nodes_from([(i, {'label': s}) for i, s in enumerate('Px')])
        eG.add_edges_from([(0, 1)])

        oG = merge_leaf_nodes(iG)
        self.assert_graphs_are_equal(eG, oG)
Exemplo n.º 2
0
    def test_quant_pred_var_pred_var_same(self):
        iG = nx.DiGraph()
        iG.add_nodes_from([(i, {
            'label': s
        }) for i, s in enumerate(['forall', 'x', '&', 'P', 'x', 'Q', 'x'])])
        iG.add_edges_from([(0, 1), (0, 2), (2, 3), (2, 5), (3, 4), (5, 6)])
        iG.graph['head_node'] = 0

        eG = nx.DiGraph()
        eG.add_nodes_from([(i, {
            'label': s
        }) for i, s in enumerate(['forall', 'x', '&', 'P', 'Q'])])
        eG.add_edges_from([(0, 1), (0, 2), (2, 3), (2, 4), (3, 1), (4, 1)])
        oG = merge_leaf_nodes(iG)
        self.assert_graphs_are_equal(eG, oG)
Exemplo n.º 3
0
    def test_quant_root_1(self):
        iG = nx.DiGraph()
        iG.add_nodes_from([(i, {
            'label': s
        }) for i, s in enumerate(['forall', 'x', 'P', 'x'])])
        iG.add_edges_from([(0, 1), (0, 2), (2, 3)])
        iG.graph['head_node'] = 0

        eG = nx.DiGraph()
        eG.add_nodes_from([(i, {
            'label': s
        }) for i, s in enumerate(['forall', 'P', 'x'])])
        eG.add_edges_from([(0, 1), (0, 2), (1, 2)])

        oG = merge_leaf_nodes(iG)
        self.assert_graphs_are_equal(eG, oG)
Exemplo n.º 4
0
    def test_quant_root_cross(self):
        iG = nx.DiGraph()
        iG.add_nodes_from([(i, {
            'label': s
        }) for i, s in enumerate(
            ['forall', 'x', 'P', 'x', '&', 'forall', 'y', 'Q', 'x', 'y'])])
        iG.add_edges_from([(0, 1), (0, 4), (2, 3), (4, 2), (4, 5), (5, 6),
                           (5, 7), (7, 8), (7, 9)])
        iG.graph['head_node'] = 0

        eG = nx.DiGraph()
        eG.add_nodes_from([(i, {
            'label': s
        }) for i, s in enumerate(['forall', 'P', 'x', '&', 'forall', 'Q', 'y'])
                           ])
        eG.add_edges_from([(0, 3), (0, 2), (1, 2), (3, 1), (3, 4), (4, 5),
                           (4, 6), (5, 2), (5, 6)])

        oG = merge_leaf_nodes(iG)
        self.assert_graphs_are_equal(eG, oG)