当前位置: 首页>>代码示例>>Python>>正文


Python Dot.set_node_defaults方法代码示例

本文整理汇总了Python中pydot.Dot.set_node_defaults方法的典型用法代码示例。如果您正苦于以下问题:Python Dot.set_node_defaults方法的具体用法?Python Dot.set_node_defaults怎么用?Python Dot.set_node_defaults使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pydot.Dot的用法示例。


在下文中一共展示了Dot.set_node_defaults方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: draw

# 需要导入模块: from pydot import Dot [as 别名]
# 或者: from pydot.Dot import set_node_defaults [as 别名]
    def draw(self, name, dname, draw_branches=True):
        """
        Writes the current graph as a PNG file

        :param str name: filename (without .png)
        :param str dname: directory of the output png
        :param draw_branches:
        :return:
        """
        from pydot import Dot, Edge
        import os

        g = Dot()
        g.set_node_defaults(color='lightgray',
                            style='filled',
                            shape='box',
                            fontname='Courier',
                            fontsize='10')
        for node in sorted(self.nodes, key=lambda x: x.num):
            if draw_branches and node.type.is_cond:
                g.add_edge(Edge(str(node), str(node.true), color='green'))
                g.add_edge(Edge(str(node), str(node.false), color='red'))
            else:
                for suc in self.sucs(node):
                    g.add_edge(Edge(str(node), str(suc), color='blue'))
            for except_node in self.catch_edges.get(node, []):
                g.add_edge(Edge(str(node),
                                str(except_node),
                                color='black',
                                style='dashed'))

        g.write(os.path.join(dname, '%s.png' % name), format='png')
开发者ID:androguard,项目名称:androguard,代码行数:34,代码来源:graph.py

示例2: create_example_graph

# 需要导入模块: from pydot import Dot [as 别名]
# 或者: from pydot.Dot import set_node_defaults [as 别名]
def create_example_graph():
    g = Dot(graph_name="workflow: example",
            labelloc="t", label="workflow: example", fontsize=18, fontcolor="blue")
    g.set_node_defaults(shape="box", fontsize=12)
    g.set_edge_defaults(fontsize=13, labeldistance=3)
    n1 = Node(name="Start")
    g.add_node(n1)
    n2 = Node(name="StepTrueEnd", color="#04B45F")
    g.add_node(n2)
    n3 = Node(name="StepFalse")
    g.add_node(n3)
    n4 = Node(name="StepFalse2")
    g.add_node(n4)
    n5 = Node(name="StepFalse3End", color="#04B45F")
    g.add_node(n5)
    e1 = true_edge(n1, n2)
    g.add_edge(e1)
    e2 = false_edge(n1, n3)
    g.add_edge(e2)
    e3 = true_edge(n3, n4)
    g.add_edge(e3)
    e_back = false_edge(n4, n1, label="back if false")
    g.add_edge(e_back)
    e4 = true_edge(n4, n5)
    g.add_edge(e4)
    return g
开发者ID:mediatum,项目名称:mediatum,代码行数:28,代码来源:graphviz.py

示例3: create_graph_from_workflow

# 需要导入模块: from pydot import Dot [as 别名]
# 或者: from pydot.Dot import set_node_defaults [as 别名]
    def create_graph_from_workflow(self, workflow):
        """
        :type workflow: Workflow
        :rtype: Dot
        """
        known_nodes = {}
        start = workflow.getStartNode()
        name = workflow.getName()
        g = Dot(graph_name=name, ranksep=1,
                labelloc="t", label="workflow: " + name, fontsize=18, fontcolor="blue")
        g.set_node_defaults(shape="box", fontsize=12)
        g.set_edge_defaults(fontsize=13, labeldistance=3)

        def add_node_rek(node):
            """Recurses through the workflow graph and adds nodes and edges.
            Repeated nodes are ignored (cycle detection).
            :type node: core.tree.Node
            """
            name = node.getName()
            if name in known_nodes:
                return known_nodes[name]
            dot_node = Node(name=name)
            g.add_node(dot_node)
            known_nodes[name] = dot_node
            logg.debug("created node %s", name)
            try:
                true_next_id = node.getTrueId()
            except:
                true_next_id = None
            if true_next_id:
                true_next = workflow.getStep(true_next_id)
                true_dot_next = add_node_rek(true_next)
                true_label = node.getTrueLabel() or " "
                g.add_edge(true_edge(dot_node, true_dot_next, label=true_label))
                logg.debug("created True edge: %s -> %s", name, true_next_id)
            try:
                false_next_id = node.getFalseId()
            except:
                false_next_id = None
            if false_next_id:
                false_next = workflow.getStep(false_next_id)
                false_dot_next = add_node_rek(false_next)
                false_label = node.getFalseLabel() or " "
                g.add_edge(false_edge(dot_node, false_dot_next, label=false_label))
                logg.debug("created False edge: %s -> %s", name, false_next_id)

            if not (true_next_id or false_next_id):
                # end node with no connections
                dot_node.set("color", "#04B45F")
            return dot_node
        # traverse from start node
        add_node_rek(start)
        return g
开发者ID:mediatum,项目名称:mediatum,代码行数:55,代码来源:graphviz.py

示例4: draw

# 需要导入模块: from pydot import Dot [as 别名]
# 或者: from pydot.Dot import set_node_defaults [as 别名]
 def draw(self, name, dname, draw_branches=True):
     from pydot import Dot, Edge
     g = Dot()
     g.set_node_defaults(color='lightgray', style='filled', shape='box',
                         fontname='Courier', fontsize='10')
     for node in sorted(self.nodes, key=lambda x: x.num):
         if draw_branches and node.type.is_cond:
             g.add_edge(Edge(str(node), str(node.true), color='green'))
             g.add_edge(Edge(str(node), str(node.false), color='red'))
         else:
             for suc in self.sucs(node):
                 g.add_edge(Edge(str(node), str(suc), color='blue'))
     g.write_png('%s/%s.png' % (dname, name))
开发者ID:Appsloka,项目名称:android-tools,代码行数:15,代码来源:graph.py

示例5: draw

# 需要导入模块: from pydot import Dot [as 别名]
# 或者: from pydot.Dot import set_node_defaults [as 别名]
    def draw(self, name, dname, draw_branches=True):
        from pydot import Dot, Edge

        g = Dot()
        g.set_node_defaults(color="lightgray", style="filled", shape="box", fontname="Courier", fontsize="10")
        for node in sorted(self.nodes, key=lambda x: x.num):
            if draw_branches and node.type.is_cond:
                g.add_edge(Edge(str(node), str(node.true), color="green"))
                g.add_edge(Edge(str(node), str(node.false), color="red"))
            else:
                for suc in self.sucs(node):
                    g.add_edge(Edge(str(node), str(suc), color="blue"))
            for except_node in self.catch_edges.get(node, []):
                g.add_edge(Edge(str(node), str(except_node), color="black", style="dashed"))

        g.write_png("%s/%s.png" % (dname, name))
开发者ID:andymg,项目名称:androguard,代码行数:18,代码来源:graph.py

示例6: SysCDiagramPlugin

# 需要导入模块: from pydot import Dot [as 别名]
# 或者: from pydot.Dot import set_node_defaults [as 别名]
class SysCDiagramPlugin():

    def initPlugin(self, signalproxy):
        """Initialise the systemc block diagram plugin"""

        self.signalproxy = signalproxy
        self.do = signalproxy.distributedObjects

        # systemc stuff and and pointer type strings needed for casting in gdb
        # because systemc objects can be systemc modules, systemc ports, etc.
        self.ctx = None
        self.ctx_pointer = None
        self.ctx_func = "sc_get_curr_simcontext()"
        self.ctx_found = False

        self.ctx_type = "(sc_core::sc_simcontext*)"
        self.port_type = "(sc_core::sc_port_base*)"
        self.module_type = "(sc_core::sc_module*)"
        self.object_type = "(sc_core::sc_object*)"
        self.prim_channel_type = "(sc_core::sc_prim_channel*)"

        # dict with a string that represents the pointer as key and
        # a nested dict with parent, children, etc as key-values
        #   dst_dict[ptr] = {"wrapper":    vw,
        #                    "name":       None,
        #                    "parent_ptr": None,
        #                    "children":   {}}
        self.sysc_modules = {}
        self.sysc_objects = {}
        self.sysc_ports = {}
        self.sysc_prim_channels = {}

        # because of how we built the interface for the tracepoints on the
        # datagraph we first need to create an file obj. We choose StringIO
        # because it uses a string as buffer and does not acces the filesystem
        self._file_obj = StringIO()
        self.image = SVGImage("SystemC Block Diagram", self._file_obj)
        self.image_wrapper = SVGDataGraphVW(self.image, self.do)

        self.signalproxy.inferiorStoppedNormally.connect(self.update)

        # hook Datagraph variable wrapper into the datagraph controller
        # after self.action.commit is called the image will be displayed at the
        # datagraph
        self.action = self.do.actions.\
            getAddSVGToDatagraphAction(self.image_wrapper,
                                       self.do.
                                       datagraphController.addVar)

        # pydot graph visualization library
        self.block_diagram = Dot(graph_type='digraph')
        self.block_diagram.set_graph_defaults(compound='true',
                                              splines='ortho',
                                              rankdir='LR')
        self.block_diagram.set_node_defaults(shape='box')

        # Needed for creating the right variables and variable wrappers from
        # the systemc pointers
        self.vwFactory = VarWrapperFactory()
        self.variableList = VariableList(self.vwFactory, self.do)

    def deInitPlugin(self):
        pass

    def evaluateExp(self, exp):
        return self.signalproxy.gdbEvaluateExpression(exp)

    def showDiagram(self):
        self.action.commit()

    def update(self):
        if not self.ctx_found and self.ctx is None:
            self.__findSimContext()
            if self.ctx is None:
                return
        else:
            # don't try to analyze if elaboration is not done
            if not cpp2py(self.ctx["m_elaboration_done"].value):
                return

        # prepare for easy information collection
        object_vec = self.ctx["m_child_objects"]

        # find all relevant information
        self.__findSysCObjects(object_vec, self.object_type, self.sysc_objects)

        # if there are no objects to draw than skip the drawing part
        # this might happen if you set the breakpoint before any objects are
        # created. This is actually catched above, but there might also be a
        # design with no objects.
        if len(self.sysc_objects.keys()) == 0:
            return

        clusters = {}
        nodes = {}

        # build pydot hierachy and add all subgraphs and nodes to the main
        # graph
        self.__buildHierachy(self.sysc_objects, clusters, nodes)
        for sptr in clusters:
#.........这里部分代码省略.........
开发者ID:dstoeg,项目名称:ricodebug,代码行数:103,代码来源:SysCDiagramPlugin.py


注:本文中的pydot.Dot.set_node_defaults方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。