def draw(self):
"""Draw the topology"""
try:
import matplotlib.pyplot as plt
except ImportError:
log.warning("matplotlib could not be found")
return
node_color = range(len(self.graph.nodes()))
pos = nx.spring_layout(self.graph,iterations=200)
nx.draw(self.graph,pos,node_color=node_color,
node_size=[100*(nx.degree(self.graph,x)**1.25) for x in self.graph.nodes()],
edge_color=['blue' for x,y,z in self.graph.edges(data=True)],
edge_cmap=plt.cm.Blues,
with_labels=True,
cmap=plt.cm.Blues)
plt.show()
评论列表
文章目录