【问题标题】:Where is draw_graphviz?draw_graphviz 在哪里?
【发布时间】:2020-12-29 22:38:37
【问题描述】:

我刚开始编程,我正在尝试在这本书中继续学习:“Natural Language Processing with Python (2009)”,但我似乎无法找到解决此错误的方法。我认为这个 graph_viz 问题之前已经讨论过,但我也知道语法规则可以改变。它应该显示一个看起来很酷的可视化。这是模块问题还是语法问题?

import networkx as nx
import matplotlib
from nltk.corpus import wordnet as wn
def traverse(graph, start, node): 
    graph.depth[node.name] =
node.shortest_path_distance(start)
        graph.add_edge(node.name, child.name)
        traverse(graph, start, child)

def hyponym_graph(start):
    G = nx.Graph()
    G.depth = {}
    traverse(G, start, start)
    return G

def graph_draw(graph):
    nx.draw_graphviz(graph,
        node_size = [16 * graph.degree(n) for n in graph],
        node_color = [graph.depth[n] for n in graoh],
        with_labels = False)
matplotlib.pyplot.show()

dog = wn.synset('dog.n.01')
graph = hyponym_graph(dog)
graph_draw(graph)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<stdin>", line 2, in graph_draw
AttributeError: module 'networkx' has no attribute 'draw_graphviz'

【问题讨论】:

标签: python graph


【解决方案1】:

它似乎已在 2.0 版中被删除以修复错误。 更改说明为here

【讨论】:

    猜你喜欢
    • 2012-07-25
    • 1970-01-01
    • 2015-11-17
    • 1970-01-01
    • 2010-09-21
    • 2012-10-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多