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


Python nx_pydot.to_pydot方法代码示例

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


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

示例1: write_graph

# 需要导入模块: from networkx.drawing import nx_pydot [as 别名]
# 或者: from networkx.drawing.nx_pydot import to_pydot [as 别名]
def write_graph(graph: nx.DiGraph, target_file, target_format="raw"):
    font = "Ubuntu Mono"
    dot = to_pydot(graph)
    for n in dot.get_node_list():
        n.set_fontname(font)
        n.set_shape("rect")
        if n.obj_dict["name"].startswith('"AlertLevel: '):
            n.set_fillcolor("#cecece")
            n.set_style("filled")
        elif n.obj_dict["name"].startswith('"Alert: '):
            n.set_fillcolor("#4e96d5")
            n.set_style("filled")
        elif n.obj_dict["name"].startswith('"Sensor: '):
            n.set_fillcolor("#25d426")
            n.set_style("filled")

    dot.write(target_file, format=target_format) 
开发者ID:sqall01,项目名称:alertR,代码行数:19,代码来源:graphExport.py

示例2: test_graph_persistence

# 需要导入模块: from networkx.drawing import nx_pydot [as 别名]
# 或者: from networkx.drawing.nx_pydot import to_pydot [as 别名]
def test_graph_persistence(default_domain, tmpdir):
    from os.path import isfile
    from networkx.drawing import nx_pydot
    from rasa.core.training.dsl import StoryFileReader
    from rasa.core.interpreter import RegexInterpreter

    story_steps = await StoryFileReader.read_from_file(
        "data/test_stories/stories.md", default_domain,
        interpreter=RegexInterpreter())
    out_file = tmpdir.join("graph.html").strpath
    generated_graph = await visualization.visualize_stories(
        story_steps,
        default_domain,
        output_file=out_file,
        max_history=3,
        should_merge_nodes=False)

    generated_graph = nx_pydot.to_pydot(generated_graph)

    assert isfile(out_file)

    with open(out_file, 'r') as graph_file:
        content = graph_file.read()

    assert 'isClient = true' in content
    assert "graph = `{}`".format(generated_graph.to_string()) in content 
开发者ID:RasaHQ,项目名称:rasa_core,代码行数:28,代码来源:test_visualization.py

示例3: test_graph_persistence

# 需要导入模块: from networkx.drawing import nx_pydot [as 别名]
# 或者: from networkx.drawing.nx_pydot import to_pydot [as 别名]
def test_graph_persistence(default_domain, tmpdir):
    from os.path import isfile
    from networkx.drawing import nx_pydot
    from rasa.core.training.dsl import StoryFileReader
    from rasa.core.interpreter import RegexInterpreter

    story_steps = await StoryFileReader.read_from_file(
        "data/test_stories/stories.md", default_domain, interpreter=RegexInterpreter()
    )
    out_file = tmpdir.join("graph.html").strpath
    generated_graph = await visualization.visualize_stories(
        story_steps,
        default_domain,
        output_file=out_file,
        max_history=3,
        should_merge_nodes=False,
    )

    generated_graph = nx_pydot.to_pydot(generated_graph)

    assert isfile(out_file)

    content = rasa.utils.io.read_file(out_file)

    assert "isClient = true" in content
    assert "graph = `{}`".format(generated_graph.to_string()) in content 
开发者ID:botfront,项目名称:rasa-for-botfront,代码行数:28,代码来源:test_visualization.py

示例4: export_to_dot

# 需要导入模块: from networkx.drawing import nx_pydot [as 别名]
# 或者: from networkx.drawing.nx_pydot import to_pydot [as 别名]
def export_to_dot(self):
        """Exports the graph to a dot format (requires pydot library)."""
        return nx_pydot.to_pydot(self).to_string() 
开发者ID:openstack,项目名称:taskflow,代码行数:5,代码来源:graph.py


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