关于节点间距,nx.spring_layout
有一个参数(k
)来调整节点之间的间距,数值越高间距越大。对于其他参数,可以通过在nx.draw
中使用相应的参数来减小边的宽度和增加节点的大小来提高图形的可视性。以下是使用随机图的示例:
from matplotlib import pyplot as plt
G = nx.fast_gnp_random_graph(100, .05)
plt.figure(figsize=(10,6))
pos = nx.spring_layout(G, k=0.8)
nx.draw(G, pos , with_labels = True, width=0.4,
node_color='lightblue', node_size=400)