def test_one_undirected(self):
        g = BinaryMixedTree(MixedGraph({0, 1, 2, 3, 4}, [(2, 3)]))
        g.update(DIRECTED_EDGE, [(frozenset([2]), frozenset([0])),
                                 (frozenset([3]), frozenset([1])),
                                 (frozenset([3]), frozenset([4]))],
                 node_creation=False)

        value = edge_choice_for_algo1(BasicTreeConstruction(g))
        expected = frozenset([frozenset([3]), frozenset([2])])

        self.assertEqual(expected, value)
Esempio n. 2
0
    def test_directed_graph(self):
        g = BinaryMixedTree(MixedGraph({0, 1, 2}))
        g.update(DIRECTED_EDGE, [(frozenset([0]), frozenset([1])),
                                 (frozenset([1]), frozenset([2]))])
        g = g.underlying_undirected_graph()

        expected = {
            frozenset([frozenset([0]),
                       frozenset([1]),
                       frozenset([2])])
        }
        value = connected_parts(g)

        self.assertEqual(value, expected)
Esempio n. 3
0
    def test_move_undirected(self):
        g = BinaryMixedTree(MixedGraph({0, 1, 2, 3, 4}, [(2, 4)]))
        g.add(frozenset([2, 3]))
        g.update(DIRECTED_EDGE, [(frozenset([2]), frozenset([0])), (frozenset([3]), frozenset([1])),
                                 (frozenset([2]), frozenset([2, 3])), (frozenset([3]), frozenset([2, 3]))],
                 node_creation=False)
        g.move_undirected_from_to(frozenset([2]), frozenset([2, 3]), {frozenset([4])})

        expected = BinaryMixedTree(MixedGraph({0, 1, 2, 3, 4}))
        expected.add(frozenset([2, 3]))
        expected.update(DIRECTED_EDGE, [(frozenset([2]), frozenset([0])), (frozenset([3]), frozenset([1])),
                                        (frozenset([2]), frozenset([2, 3])), (frozenset([3]), frozenset([2, 3]))],
                        node_creation=False)
        expected.add_undirected(frozenset([4]), frozenset([2, 3]))

        self.assertEqual(g, expected)
    def test_init_one_undirected(self):
        g = BinaryMixedTree(MixedGraph({0, 1, 2, 3, 4}, [(2, 3)]))
        g.update(DIRECTED_EDGE, [(frozenset([2]), frozenset([0])),
                                 (frozenset([3]), frozenset([1])),
                                 (frozenset([3]), frozenset([4]))],
                 node_creation=False)
        v_xy = g.add_union(frozenset([2]), frozenset([3]))

        expected = BinaryMixedTree(MixedGraph({0, 1, 2, 3, 4}))
        expected.add(frozenset([2, 3]))
        expected.update(DIRECTED_EDGE, [(frozenset([2]), frozenset([0])),
                                        (frozenset([3]), frozenset([1])),
                                        (frozenset([3]), frozenset([4])),
                                        (frozenset([2]), frozenset([2, 3])),
                                        (frozenset([3]), frozenset([2, 3]))],
                        node_creation=False)

        self.assertEqual(g, expected)
        self.assertEqual(v_xy, frozenset([2, 3]))