Exemplo n.º 1
0
    def test_one_vertex_homogeneous_subset(self):
        g = BinaryMixedTree(MixedGraph({0}))

        value = g.homogeneous_subset()
        expected = {frozenset([0])}

        self.assertEqual(value, expected)
    def test_edges_in_homogeneous_simple_graph(self):
        g = BinaryMixedTree(MixedGraph({0, 1}))
        g.add_directed(frozenset([0]), frozenset([1]))

        value = edges_in_homogeneous_subset(g, g.homogeneous_subset())
        expected = []

        self.assertEqual(value, expected)
    def test_edges_in_homogeneous(self):
        g = BinaryMixedTree(MixedGraph({0, 1, 2, 3, 4, 5}, [(0, 1), (1, 2), (3, 4), (4, 5)]))
        g.add_directed(frozenset([2]), frozenset([3]))

        value = edges_in_homogeneous_subset(g, g.homogeneous_subset())
        expected = [frozenset([frozenset([0]), frozenset([1])]), frozenset([frozenset([1]), frozenset([2])])]

        self.assertEqual(value, expected)
Exemplo n.º 4
0
    def test_simple_homogeneous_subset(self):
        g = BinaryMixedTree(MixedGraph({0, 1, 2}, [(0, 2)]))
        g.add_directed(frozenset([0]), frozenset([1]))

        value = g.homogeneous_subset()
        expected = {frozenset([0]), frozenset([2])}

        self.assertEqual(value, expected)
Exemplo n.º 5
0
    def test_homogeneous_subset_2(self):
        g = BinaryMixedTree(
            MixedGraph({0, 1, 2, 3, 4, 5}, [(1, 2), (2, 3), (3, 4), (4, 5)]))
        g.add_directed(frozenset([0]), frozenset([1]))

        value = g.homogeneous_subset()
        expected = {frozenset([0])}

        self.assertEqual(value, expected)
    def test_edge_choice(self):
        g = HyperGraph(frozenset([frozenset([i]) for i in range(1, 7)]))
        for i in range(1, 7):
            g.add_edge(frozenset([frozenset([i])]))
        g.add_edge(frozenset([frozenset([i]) for i in range(1, 7)]))
        g.add_edge(frozenset([frozenset([1]), frozenset([2])]))
        g.add_edge(frozenset([frozenset([4]), frozenset([5])]))
        g.add_edge(frozenset([frozenset([5]), frozenset([6])]))
        g.add_edge(frozenset([frozenset([4]), frozenset([5]), frozenset([6])]))
        g.add_edge(frozenset([frozenset([3]), frozenset([4]), frozenset([5])]))
        g.add_edge(frozenset([frozenset([3]), frozenset([4]), frozenset([5]), frozenset([6])]))
        g.add_edge(frozenset([frozenset([1]), frozenset([2]), frozenset([3]), frozenset([4]), frozenset([5])]))

        t = BinaryMixedTree(MixedGraph({1, 2, 3, 4, 5, 6}, [(1, 3), (3, 6), (1, 5)]))
        t.add_directed(frozenset([1]), frozenset([2]))
        t.add_directed(frozenset([3]), frozenset([4]))

        self.assertEqual(edges_in_homogeneous_subset(t, t.homogeneous_subset()), list(t.edges[0]))

        value = edge_choice_for_algo3(BasicTreeConstruction(t, s_0(t), g))
        self.assertEqual(value, frozenset([frozenset([1]), frozenset([3])]))
    def test_edge_choice_for_algo3(self):
        h = HyperGraph(
            frozenset([frozenset([1]), frozenset([2]), frozenset([3]), frozenset([4]), frozenset([5]), frozenset([6])]),
            frozenset([frozenset([frozenset([1])]),
                       frozenset([frozenset([2])]),
                       frozenset([frozenset([3])]),
                       frozenset([frozenset([4])]),
                       frozenset([frozenset([5])]),
                       frozenset([frozenset([6])]),
                       frozenset([frozenset([4]), frozenset([5])]),
                       frozenset([frozenset([5]), frozenset([6])]),
                       frozenset([frozenset([1]), frozenset([2]), frozenset([3]), frozenset([4]), frozenset([5]),
                                  frozenset([6])])]))

        g = BinaryMixedTree(MixedGraph({1, 2, 3, 4, 5, 6}, [(1, 2), (2, 4), (4, 3), (4, 5), (5, 6)]))
        map = s_0(g)

        value = edge_choice_for_algo3(BasicTreeConstruction(g, map, h))
        expected = frozenset({frozenset([4]), frozenset([5])})

        self.assertEqual(list(g.edges[0]), edges_in_homogeneous_subset(g, g.homogeneous_subset()))
        self.assertEqual(expected, value)