本文整理汇总了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)
示例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
示例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
示例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()