topology.py 文件源码

python
阅读 74 收藏 0 点赞 0 评论 0

项目:ez-segway 作者: thanh-nguyen-dang 项目源码 文件源码
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()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号