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_delta_z(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}, [(3, 6), (1, 5)]))
        s = s_0(t)
        s[frozenset([1, 3])] = {frozenset([1]), frozenset([3])}
        t.add(frozenset([1, 3]))
        t.add_directed(frozenset([1]), frozenset([2]))
        t.add_directed(frozenset([3]), frozenset([4]))

        expected = {frozenset([5])}
        value = delta_z_subset_algo3(BasicTreeConstruction(t, s, g), frozenset([frozenset([5])]),
                                     frozenset([1, 3]), frozenset([1]))
        self.assertEqual(expected, value)
Exemple #3
0
    def test_hypergraph_2(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}, [(3, 6), (1, 5), (1, 3)]))
        t.add_directed(frozenset([1]), frozenset([2]))
        t.add_directed(frozenset([3]), frozenset([4]))

        next_tree, next_map = BasicTreeConstruction(t, s_0(t), g).step(StratAlgo3())

        self.assertEqual({frozenset([1]): {frozenset([1])},
                          frozenset([2]): {frozenset([2])},
                          frozenset([3]): {frozenset([3])},
                          frozenset([4]): {frozenset([4])},
                          frozenset([5]): {frozenset([5])},
                          frozenset([6]): {frozenset([6])},
                          frozenset([1, 3]): {frozenset([1]), frozenset([3])}
                          }, next_map)

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

        self.assertEqual(expected_tree, next_tree)