0
documentation hereに従って、read_dot()
メソッドはファイルハンドルを入力として受け取ります。networkxのドットグラフをファイルではなく文字列から読み取る
私がしなければしても、それは正常に動作し、dotFile
はファイルハンドルである
g = nx.drawing.nx_agraph.read_dot(dotFile)
。しかし、変数にdot
のフォーマットされたグラフがある場合、どのようにnxグラフ形式でインポートできますか?
編集 - 私の変数は
dotFormat = """
digraph G{
edge [dir=forward]
node [shape=plaintext]
0 [label="0 (None)"]
0 -> 7 [label="root"]
1 [label="1 (The)"]
4 [label="4 (great Indian Circus)"]
4 -> 4 [label="compound"]
4 -> 1 [label="det"]
4 -> 4 [label="amod"]
5 [label="5 (is)"]
6 [label="6 (in)"]
7 [label="7 (Mumbai)"]
7 -> 6 [label="case"]
7 -> 5 [label="cop"]
7 -> 4 [label="nsubj"]
}
"""
EDIT 2、このようになります - 私もpy_dot
を読んで、このようnetworkxグラフに変換してみました。その後
pg = pydot.graph_from_dot_data(dotFormat)
g = nx.nx_pydot.from_pydot(pg)
私は何をすべきエラー
if P.get_strict(None): # pydot bug: get_strict() shouldn't take argument
AttributeError: 'list' object has no attribute 'get_strict'
次のですか?