0
this questionで拡張すると、エッジ属性の値のみを表示できますか?現在、私は唯一の属性ではなく、キー自体の値をしたいしかし、私はこのnetworkxグラフのエッジ属性値を表示
を取得しています
paragraph = """
John is a computer scientist. John eats mango. John has an elder sister named Mary.
"""
mg.make_graph(paragraph) #This is my custom method, which creates the following graph
nx.draw(mg,pos=graphviz_layout(mg,prog='neato'),arrows=True,with_labels=True,alpha=0.5,linewidths=0.5,scale=2)
nx.draw_networkx_edge_labels(mg, pos = graphviz_layout(mg, prog='neato'),labels = nx.get_edge_attributes(mg,'label'))
plt.show()
を使用して例えば
、。 (単語「ラベル」を印刷してはいけません。
私はnx.get_edge_attributes(mg,'label')
が辞書を返しますが、labels
パラメータでnx.get_edge_attributes(mg,'label').values()
を使用して、また、唯一の値で表示されているグラフにはなりませんので、これは理解しています。
?。私はこれを達成するにはどうすればよい
eのeのe ["label"] mg.edges()} TypeError:タプルのインデックスはstrではなく整数でなければなりません –
はい、正確な答えではありませんでした。しかし、これを試してください: 'mg.get_edge_data(e)[" label "]'または 'e [" label "]'の代わりにmg [e [0]] [e [1]] ["label"] ' –
何も働いていない、私は、関数自体がパラメータとして辞書を取ると思います。 –