先看
看完了都解决不了怎么办
# pip show networkx
Name: networkx
Version: 2.3
Summary: Python package for creating and manipulating graphs and networks
Home-page: http://networkx.github.io/
Author: Aric Hagberg
Author-email: hagberg@lanl.gov
License: BSD
Location: c:\python36\lib\site-packages
Requires: decorator
Required-by:
原来 graphviz_layout 在2.3中换成nx.nx_agraph.graphviz_layout
https://networkx.github.io/documentation/stable/tutorial.html#drawing-graphs
pos = nx.nx_agraph.graphviz_layout(G)
#%%
import networkx as nx
import matplotlib.pyplot as plt
# try:
# from networkx import graphviz_layout
# except ImportError:
# raise ImportError("This example needs Graphviz and either PyGraphviz or Pydot")
#%%
G=nx.balanced_tree(3,5)
#pos=nx.graphviz_layout(G,prog='twopi',args='')
pos = nx.nx_agraph.graphviz_layout(G,prog='twopi',args='')
plt.figure(figsize=(8,8))
nx.draw(G,pos,node_size=20,alpha=0.5,node_color="blue", with_labels=False)
plt.axis('equal')
#plt.savefig('circular_tree.png')
plt.show()
#%%