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


Python networkx.write_dot方法代码示例

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


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

示例1: visualize_dag

# 需要导入模块: import networkx [as 别名]
# 或者: from networkx import write_dot [as 别名]
def visualize_dag(dg=None, plot_nx=False, plot_graphviz=True, write_dot=True,
                  prog='dot'):
    """For interactive use"""
    import webbrowser
    if not dg:
        dg = build_dag()
    dg = nx.relabel_nodes(
        dg,
        {x: "%s\n%s" % (x, node.get_job_id_template(x)[0]) for x in dg.node})
    if plot_nx:
        nx.draw_graphviz(dg, prog=prog)
    if write_dot or plot_graphviz:
        tmpf = tempfile.mkstemp(suffix='.dot', prefix='stolos_dag_')[1]
        nx.write_dot(dg, tmpf)
        os.popen('{1} {0} -Tpng > {0}.png'.format(tmpf, prog))
        print("saved to %s.png" % tmpf)
        if plot_graphviz:
            webbrowser.open(tmpf + '.png') 
开发者ID:sailthru,项目名称:stolos,代码行数:20,代码来源:build.py

示例2: __init__

# 需要导入模块: import networkx [as 别名]
# 或者: from networkx import write_dot [as 别名]
def __init__(self, _analysis) :
        self.__analysis = _analysis

        try :
            from networkx import DiGraph
            from networkx import draw_graphviz, write_dot
        except ImportError :
            error("module networkx not found")

        self.__G = DiGraph()

        for m in self.__analysis.get_methods() :
            for bb in m.basic_blocks.get() :
                for trace in bb.stack_traces.get() :
                    for mre in jvm.MATH_JVM_RE :
                        if mre[0].match( trace[2].get_name() ) :
                            for i in trace[3].gets() :
                                self._add( str(i) ) 
开发者ID:xtiankisutsa,项目名称:MARA_Framework,代码行数:20,代码来源:jvm_generate.py

示例3: write_dot

# 需要导入模块: import networkx [as 别名]
# 或者: from networkx import write_dot [as 别名]
def write_dot(self, dotfile):
        """ Outputs the word graph in dot format in the specified file. """
        nx.write_dot(self.graph, dotfile)
    #-B-----------------------------------------------------------------------B-

#~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
# ] Ending word_graph class
#~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~



#~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
# [ Class keyphrase_reranker
#~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ 
开发者ID:sildar,项目名称:potara,代码行数:16,代码来源:takahe.py

示例4: show

# 需要导入模块: import networkx [as 别名]
# 或者: from networkx import write_dot [as 别名]
def show(self) :
        print self.__G.node
        print self.__G.edge

        #draw_graphviz(self.__G)
        #write_dot(self.__G,'file.dot') 
开发者ID:xtiankisutsa,项目名称:MARA_Framework,代码行数:8,代码来源:jvm_generate.py

示例5: write_dot

# 需要导入模块: import networkx [as 别名]
# 或者: from networkx import write_dot [as 别名]
def write_dot(self, dotfile):
        """ Outputs the word graph in dot format in the specified file. """
        nx.write_dot(self.graph, dotfile)
    #-B-----------------------------------------------------------------------B- 
开发者ID:StevenLOL,项目名称:AbTextSumm,代码行数:6,代码来源:WGGraph.py

示例6: visualize

# 需要导入模块: import networkx [as 别名]
# 或者: from networkx import write_dot [as 别名]
def visualize(event, outputname):
    g = nx.DiGraph()
    for i, p in enumerate(event.particles):
        g.add_node(i, attr_dict=p.__dict__)
        name = pypdt.particle(p.id).name
        greek = [
            "gamma",
            "nu",
            "mu",
            "tau",
            "rho",
            "Xi",
            "Sigma",
            "Lambda",
            "omega",
            "Omega",
            "Alpha",
            "psi",
            "phi",
            "pi",
            "chi",
        ]
        for greekname in greek:
            if greekname in name:
                name = name.replace(greekname, "\\" + greekname)
        if "susy-" in name:
            name = name.replace("susy-", "\\tilde ")
        g.node[i].update(texlbl="${}$".format(name))
    for i, p in enumerate(event.particles):
        for mom in p.mothers():
            g.add_edge(event.particles.index(mom), i)
    nx.write_dot(g, "event.dot")
    p = subprocess.Popen(["dot2tex", "event.dot"], stdout=subprocess.PIPE)
    tex2pix.Renderer(texfile=p.stdout).mkpdf(outputname)
    subprocess.check_call(["pdfcrop", outputname, outputname])
    os.remove("event.dot") 
开发者ID:scikit-hep,项目名称:pylhe,代码行数:38,代码来源:__init__.py

示例7: showGraph

# 需要导入模块: import networkx [as 别名]
# 或者: from networkx import write_dot [as 别名]
def showGraph(root, filename='test.dot'):
    import matplotlib.pyplot as plt
    g, good, bad, mid = makeGraph(root)
    plt.figure(figsize=(10, 10), dpi=80)
    nx.write_dot(g, filename)

    # same layout using matplotlib with no labels
    pos = nx.graphviz_layout(g, prog='dot')

    nx.draw_networkx_edges(g, pos, width=1.0, alpha=1., arrows=False)
    ALPHA = 1.0
    colors = [(0.2, 0.8, 0.2)] * len(good)
    nx.draw_networkx_nodes(g, pos,
                           nodelist=good,
                           node_color=colors,
                           alpha=ALPHA,

                           node_shape='s',
                           node_size=1600)
    colors = [(0.9, 0.4, 0.4)] * len(bad)
    nx.draw_networkx_nodes(g, pos,
                           nodelist=bad,
                           node_color=colors,
                           alpha=ALPHA,
                           node_shape='8',
                           node_size=1600)
    colors = [(0.8, 0.8, 0.8)] * len(mid)
    nx.draw_networkx_nodes(g, pos,
                           nodelist=mid,
                           node_color=colors,
                           node_shape='s',
                           alpha=ALPHA,
                           node_size=1600)
    labels = {}
    lookup = {
        "NODE": "0",
        "Default": "D",
        "Left": "L",
        "Right": "R",
        "Pass": "P",
        "Stop": "S",
        "Wait": "W",
        "Follow": "F",
        "Finish": "C",
    }
    for name in good:
        labels[name] = lookup[name.split(' ')[0]]
    for name in bad:
        labels[name] = lookup[name.split(' ')[0]]
    for name in mid:
        labels[name] = lookup[name.split(' ')[0]]
    nx.draw_networkx_labels(g, pos, labels, font_size=20)

    plt.axis('off')
    plt.show() 
开发者ID:jhu-lcsr,项目名称:costar_plan,代码行数:57,代码来源:graph.py


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