Пример #1
0
 def construct_graph(source, target, color):
     attr_graph = MutableAttributeGraph(
         default_edge_attrs=dict({EdgeAttributes.COLOR: color}))
     attr_graph.add_node(source)
     attr_graph.add_node(target)
     attr_graph.add_edge(source, target)
     return attr_graph
Пример #2
0
    def aggregate_graph(mapper, ignore_external, exceptions, file_graph):
        assert (isinstance(mapper, AggregateMapper))
        pseudomodule_graph = MutableAttributeGraph()
        for edge in file_graph.edges():
            from_node = mapper.get_output_aggregate_for_individual(
                edge.get_from_node())
            if mapper.is_file_in_input_aggregates(edge.get_to_node()):
                to_node = mapper.get_output_aggregate_for_individual(
                    edge.get_to_node())
                if not (from_node == to_node or
                        (from_node, to_node) in exceptions):
                    pseudomodule_graph.add_edge_and_nodes(from_node, to_node)
                else:
                    pseudomodule_graph.add_node(from_node)
                    pseudomodule_graph.add_node(to_node)
            elif not ignore_external:
                to_node = edge.get_to_node()
                pseudomodule_graph.add_edge_and_nodes(from_node, to_node)
            else:
                pseudomodule_graph.add_node(from_node)

        # TODO warum wird das gemacht?
        for node in pseudomodule_graph.nodes_raw():
            pseudomodule_graph.set_node_attrs(node, {NodeAttributes.LABEL: ""})

        return pseudomodule_graph
Пример #3
0
    def filter_graph(full_graph, dependency_filter_config, internal_modules):
        """
        
        @param full_graph:
        @param dependency_filter_config:
        @param internal_modules: All internal modules are added to the graph even if they are not 
            connected to any other module. If the graph is focused on a particular module group, 
            this applies only if they belong to this module group.
        """
        graph = MutableAttributeGraph()
        for module in internal_modules:
            if not dependency_filter_config.skip_module(module) and not dependency_filter_config.skip_module_as_source(module):
                graph.add_node(module)
        for edge in full_graph.edges():
            source = str(edge.get_from_node())
            target = str(edge.get_to_node())
            if not (dependency_filter_config.skip_module(source) \
                    or dependency_filter_config.skip_module(target) \
                    or dependency_filter_config.skip_module_as_source(source) \
                    or dependency_filter_config.skip_module_as_target(target) \
                    or dependency_filter_config.skip_edge(source, target)):
                graph.add_edge_and_nodes(source, target)
            else:
                if dependency_filter_config.skip_module_as_source(source) or dependency_filter_config.skip_edge(source, target):
                    #self.__logger.debug("recording skipped edge source %s->%s", source, target)
                    graph.set_node_attrs(source, {NodeAttributes.SKIPPED_FROM_EDGE: True}, True)
                if dependency_filter_config.skip_module_as_target(target) or dependency_filter_config.skip_edge(source, target):
                    #self.__logger.debug("recording skipped edge target %s->%s", source, target)
                    graph.set_node_attrs(target, {NodeAttributes.SKIPPED_TO_EDGE: True}, True)

        if dependency_filter_config.focus_on_node_groups:
            node_grouper = dependency_filter_config.get_module_grouper()
            exception_func = lambda node: node_grouper.get_node_group_prefix(node) in dependency_filter_config.focus_on_node_groups
        else:
            exception_func = lambda node: False
        graph.delete_unconnected_nodes(exception_func)
        return graph