コード例 #1
0
 def test_three_and_three_but_diff_numbers(self, _, algorithm: GraphDiffAlgorithm):
     graph1 = rnr_graph().add_node(lr_node(1, 1)).add_node(lr_node(1, 2)).add_node(lr_node(1, 3))
     graph2 = rnr_graph().add_node(lr_node(1, 1)).add_node(lr_node(1, 3)).add_node(lr_node(1, 3))
     graph1.add_edge(lr_node(1, 1), lr_node(1, 2)).add_edge(lr_node(1, 3), lr_node(1, 2))
     graph2.add_edge(lr_node(1, 1), lr_node(1, 3)).add_edge(lr_node(1, 2), lr_node(1, 3))
     self.template_test(graph1, graph2, 4, algorithm)
     self.template_test(graph2, graph1, 4, algorithm)
コード例 #2
0
 def test_three_and_three_with_dif_labels_and_edges_to_center(self, _, algorithm):
     graph1 = rnr_graph().add_node(lr_node(1, 1)).add_node(lr_node(2, 1)).add_node(lr_node(3, 1))
     graph2 = rnr_graph().add_node(lr_node(1, 1)).add_node(lr_node(2, 1)).add_node(lr_node(3, 1))
     graph1.add_edge(lr_node(1, 1), lr_node(2, 1)).add_edge(lr_node(3, 1), lr_node(2, 1))
     graph2.add_edge(lr_node(1, 1), lr_node(2, 1)).add_edge(lr_node(3, 1), lr_node(2, 1))
     self.template_test(graph1, graph2, 4, algorithm)
     self.template_test(graph2, graph1, 4, algorithm)
コード例 #3
0
 def template_x_and_y_test_comp1(self, x: int, y: int, algorithm):
     graph1 = rnr_graph()
     graph2 = rnr_graph()
     for i in range(1, x + 1):
         graph1.add_node(lr_node(1, i))
     for i in range(1, y + 1):
         graph2.add_node(lr_node(1, i))
     i = min(x, y)
     self.template_test(graph1, graph2, i, algorithm)
     if x != y:
         self.template_test(graph2, graph1, i, algorithm)
コード例 #4
0
    def convert(self, workflow: Workflow) -> GraphWithRepetitiveNodesWithRoot:
        graph = rnr_graph()
        from collections import defaultdict
        number_of_blocks = defaultdict(int)

        for block in workflow:
            number_of_blocks[block] += 1
            graph.add_node(lr_node(self.block_id(block), number_of_blocks[block]))

        for (from_block, from_num, _), a2 in workflow.items():
            for to_block, to_num, _ in a2:
                graph.add_edge_exp(lr_node(self.block_id(from_block), from_num),
                                   lr_node(self.block_id(to_block), to_num))

        for (from_block, from_num), a2 in workflow.items_by_exc():
            for to_block, to_num in a2:
                graph.add_edge_exp(lr_node(self.block_id(from_block), from_num),
                                   lr_node(self.block_id(to_block), to_num))

        return graph
コード例 #5
0
    def convert(self, workflow: Workflow) -> GraphWithRepetitiveNodesWithRoot:
        graph = rnr_graph()

        from collections import defaultdict
        number_of_blocks = defaultdict(int)

        for block in workflow:
            number_of_blocks[block] += 1
            block_node = lr_node(self.block_id(block), number_of_blocks[block])
            graph.add_node(block_node)

            for nest in block.operation.inputs:
                nest_node = lr_node(self.input_nest_id(block, nest),
                                    number_of_blocks[block])
                graph.add_node(nest_node)
                graph.add_edge_exp(nest_node, block_node)

            for nest in block.operation.outputs:
                nest_node = lr_node(self.output_nest_id(block, nest),
                                    number_of_blocks[block])
                graph.add_node(nest_node)
                graph.add_edge_exp(block_node, nest_node)

        for (from_block, from_num, output_nest), a2 in workflow.items():
            for to_block, to_num, input_nest in a2:
                graph.add_edge_exp(
                    lr_node(self.output_nest_id(from_block, output_nest),
                            from_num),
                    lr_node(self.input_nest_id(to_block, input_nest), to_num))

        for (from_block, from_num), a2 in workflow.items_by_exc():
            for to_block, to_num in a2:
                graph.add_edge_exp(
                    lr_node(self.block_id(from_block), from_num),
                    lr_node(self.block_id(to_block), to_num))

        return graph
コード例 #6
0
 def test_three_and_three_with_dif_labels(self, _, algorithm):
     graph1 = rnr_graph().add_node(lr_node(1, 1)).add_node(lr_node(2, 1)).add_node(lr_node(3, 1))
     graph2 = rnr_graph().add_node(lr_node(1, 1)).add_node(lr_node(2, 1)).add_node(lr_node(3, 1))
     self.template_test(graph1, graph2, 3, algorithm)
     self.template_test(graph2, graph1, 3, algorithm)
コード例 #7
0
 def test_two_with_edge_and_two_with_edge(self, _, algorithm):
     graph1 = rnr_graph().add_edge(lr_node(1, 2), lr_node(1, 1))
     graph2 = rnr_graph().add_edge(lr_node(1, 2), lr_node(1, 1))
     self.template_test(graph1, graph2, 2, algorithm)
     self.template_test(graph2, graph1, 2, algorithm)
コード例 #8
0
 def setUp(self):
     self.test_graph = rnr_graph()