當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。