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


Python pygraphviz.AGraph类代码示例

本文整理汇总了Python中pygraphviz.AGraph的典型用法代码示例。如果您正苦于以下问题:Python AGraph类的具体用法?Python AGraph怎么用?Python AGraph使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: run_graph

 def run_graph(dot):
     """ Runs graphviz to see if the syntax is good. """
     graph = AGraph()
     graph = graph.from_string(dot)
     extension = 'png'
     graph.draw(path='output.png', prog='dot', format=extension)
     sys.exit(0)
开发者ID:aaron0browne,项目名称:eralchemy,代码行数:7,代码来源:test_intermediary_to_dot.py

示例2: build_graph

def build_graph(ts):
    g = AGraph(directed=True)
    g.add_edges_from(ts.ts.todok().keys())
    g.graph_attr['overlap'] = 'scalexy'
    for n, s in zip(g.nodes(), ts._pwa.states):
        n.attr['label'] = s
    return g
开发者ID:fran-penedo,项目名称:param-synth-web,代码行数:7,代码来源:graph.py

示例3: get_graphviz

    def get_graphviz(self, triple_args_function=None,
                     ignore_properties=VIS_IGNORE_PROPERTIES):
        """
        Create a pygraphviz graph from the tree
        """
        def _id(node):
            return node.uri.split("/")[-1]
        g = AGraph(directed=True)
        triples = list(self.get_triples())
        nodeset = set(chain.from_iterable((t.subject, t.object)
                                          for t in triples))
        for n in nodeset:
            label = "%s: %s" % (n.id, n.word)
            for k, v in n.__dict__.iteritems():
                if k not in ignore_properties:
                    label += "\\n%s: %s" % (k, v)
            g.add_node(_id(n), label=label)

        # create edges
        for triple in triples:
            kargs = (triple_args_function(triple)
                     if triple_args_function else {})
            if 'label' not in kargs:
                kargs['label'] = triple.predicate
            g.add_edge(_id(triple.subject), _id(triple.object), **kargs)
        # some theme options
        g.graph_attr["rankdir"] = "BT"
        g.node_attr["shape"] = "rect"
        g.edge_attr["edgesize"] = 10
        g.node_attr["fontsize"] = 10
        g.edge_attr["fontsize"] = 10

        return g
开发者ID:anonymous-1,项目名称:syntaxrules,代码行数:33,代码来源:syntaxtree.py

示例4: graphviz_to_firebase

def graphviz_to_firebase(dirname,filename):
    """
    since several chars must be escaped from firebase keys,
    (see #http://stackoverflow.com/questions/19132867/adding-firebase-data-dots-and-forward-slashes
    we can't directly use them as keys so:
    - we use integer i as key,
    - "nodes" dict maps node name to i to preserve edges coherency
    - node name is kept as default node label
    """
    f=os.path.join(dirname, filename)
    graph=filename.split('.')[0]
    print('processing %s'%f),
    agraph=AGraph(f)
    nodes={}
    for i,node in enumerate(agraph.iternodes()):
        nodes[node]=i
        attrs={}
        attrs.update(agraph.node_attr)
        attrs['label']=node #default label is node id
        attrs.update(node.attr)
        key='%s/node/%d'%(graph,i)
        ref.patch(key,attrs)
        print('.'),
    for i,edge in enumerate(agraph.iteredges()):
        attrs={}
        attrs.update(agraph.edge_attr)
        attrs.update(edge.attr)
        attrs['source']=nodes[edge[0]]
        attrs['target']=nodes[edge[1]]
        #edges are added as attributes of their destination node
        key='%s/edge/%d'%(graph,i)
        ref.patch(key,attrs)
        print('-'),
    logging.info('ok')
开发者ID:goulu,项目名称:firegraph,代码行数:34,代码来源:graphviz2firegraph.py

示例5: render

    def render(self, filename):
        g = AGraph(strict=False, directed=True)

        # create nodes
        for frame_id, node in self.callers.items():
            label = "{ %s }" % node
            g.add_node(frame_id, shape='Mrecord', label=label,
                       fontsize=13, labelfontsize=13)

        # create edges
        for frame_id, node in self.callers.items():
            child_nodes = []
            for child_id in node.child_methods:
                child_nodes.append(child_id)
                g.add_edge(frame_id, child_id)

            # order edges l to r
            if len(child_nodes) > 1:
                sg = g.add_subgraph(child_nodes, rank='same')
                sg.graph_attr['rank'] = 'same'
                prev_node = None
                for child_node in child_nodes:
                    if prev_node:
                        sg.add_edge(prev_node, child_node, color="#ffffff")
                    prev_node = child_node

        g.layout()
        g.draw(path=filename, prog='dot')

        print("callviz: rendered to %s" % filename)
        self.clear()
开发者ID:xapiton,项目名称:rcviz,代码行数:31,代码来源:rcviz.py

示例6: draw

 def draw(self):
     tree = self.to_tree()
     A = AGraph(tree)
     if not self.filename:
         self.filename = input('Please input a filename:')
     A.draw('temp/{}.jpg'.format(self.filename),
            format='jpg', prog='fdp')
开发者ID:ccdd9451,项目名称:GS-Parser,代码行数:7,代码来源:s_browser.py

示例7: path_graph

def path_graph(nodes):
    graph = AGraph(directed=True)

    for node in nodes:
        graph.add_node(node, shape='rectangle')

    graph.add_path(nodes)
    return graph
开发者ID:lorenanicole,项目名称:pytenn2016,代码行数:8,代码来源:diagrams.py

示例8: processLines

    def processLines(self):
        if len(self.lines) == 0:
            return
        
        self.identifier = self.lines[0][2:]

        s = '\n'.join(self.lines)
        A = AGraph()
        G = A.from_string(s)
        self.processGraph(G)
开发者ID:a0x77n,项目名称:joern-tools,代码行数:10,代码来源:GraphvizTool.py

示例9: dot_to_graph

def dot_to_graph(dot, output_path):
    """
    Render by calling graphviz the figure on the output path.
    :param dot: str with the
    :param output_path:
    :return:
    """
    from pygraphviz import AGraph
    graph = AGraph().from_string(dot)
    graph.draw(path=output_path, prog='dot')
开发者ID:ColinHuang,项目名称:draw-compose,代码行数:10,代码来源:draw_compose.py

示例10: _render

	def _render(self, costs=False, word_probs=False, highlight_best=False):	
		from pygraphviz import AGraph
                graph = AGraph(directed=True)
                for node_id, node_label in self.nodes.iteritems():
                        attributes = self._node_attr(node_id, costs=costs, word_probs=word_probs)
			graph.add_node(node_id, **attributes)
                for (parent_node_id, child_node_id) in self.edges:
                        graph.add_edge(parent_node_id, child_node_id)
		self.graph = graph
		if highlight_best:
			self._highlight_best()
开发者ID:andre-martins,项目名称:nematus,代码行数:11,代码来源:hypgraph.py

示例11: __call__

 def __call__(self):
     self.request.response.setHeader('Content-Type', 'image/svg+xml')
     self.request.response.setHeader('Content-Disposition',
                                     'inline; filename=%s.svg' % \
                                     self.context.getId())
     tfile = tempfile.NamedTemporaryFile(suffix='.svg')
     gv = generate_gv(self.context)
     ag = AGraph(string=gv)
     ag.layout()
     ag.draw(path=tfile, format='svg', prog='dot')
     tfile.seek(0)
     return tfile.read()
开发者ID:SyZn,项目名称:collective.wfautodoc,代码行数:12,代码来源:views.py

示例12: startGraph

def startGraph():
    # We maintain this globally to make it accessible, pylint: disable=global-statement
    global graph

    if Options.shallCreateGraph():
        try:
            from pygraphviz import AGraph  # pylint: disable=I0021,import-error

            graph = AGraph(name="Optimization", directed=True)
            graph.layout()
        except ImportError:
            warning("Cannot import pygraphviz module, no graphing capability.")
开发者ID:kayhayen,项目名称:Nuitka,代码行数:12,代码来源:Graphs.py

示例13: to_dot

 def to_dot(self, filename, edges):
     from pygraphviz import AGraph
     dot = AGraph(directed=True)
     for n in edges.keys():
         dot.add_node(str(n))
         if lib.qcgc_arena_get_blocktype(ffi.cast("cell_t *", n)) not in [
                 lib.BLOCK_BLACK, lib.BLOCK_WHITE]:
             node = dot.get_node(str(n))
             node.attr['color'] = 'red'
     for n in edges.keys():
         if edges[n] is not None:
             dot.add_edge(str(n), str(edges[n]))
     dot.layout(prog='dot')
     dot.draw(filename)
开发者ID:ntruessel,项目名称:qcgc,代码行数:14,代码来源:test_stressing.py

示例14: draw_workflow

def draw_workflow(filename, workflow):
    dot = AGraph(directed=True, strict=False)  # (comment="Computing scheme")
    for i, n in workflow.nodes.items():
        dot.add_node(i, label="{0} \n {1}".format(n.foo.__name__, _format_arg_list(n.bound_args.args, None)))

    for i in workflow.links:
        for j in workflow.links[i]:
            dot.add_edge(i, j[0], j[1].name)  # , headlabel=j[1].name, labeldistance=1.8)
    dot.layout(prog="dot")

    dot.draw(filename)
开发者ID:NLeSC,项目名称:noodles,代码行数:11,代码来源:draw_workflow.py

示例15: run

    def run(self):
        options = self.options
        filename = self.arguments[0]
        if self.content:
            content = u'\n'.join(self.content)
            ofilename = filename + '.' + self.outputformat
        else:
            content = open(filename).read().decode(options.get('encoding','utf-8'))
            ofilename = os.path.splitext(filename)[0] + '.' + self.outputformat

        g = AGraph(string=content)
        g.layout(prog='dot')
        opath = os.path.join(OUTPUT_DIR, ofilename)
        g.draw(opath, 'png')
        self.arguments[0] = opath
        return super(GraphvizBlock, self).run()
开发者ID:yihuang,项目名称:huangyilib,代码行数:16,代码来源:graphviz_support.py


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