首页 > Web开发 > 详细

Draw graph(network) with nx_pydot in networkx

时间:2020-07-23 15:19:35      阅读:69      评论:0      收藏:0      [点我收藏+]

Draw graph(network) with nx_pydot in networkx

with nx_pydot in nx.drawing, we can have more plotting style of network/ tree/ graph.

Here is a simple sample:

import networkx as nx

g=nx.DiGraph()

edgelist = [(0, 1), (1, 12), (2, 12), (3, 17), (4, 11), (5, 4), (6, 10), (7, 12), (8, 14), (9, 14), (10, 11),
            (11, 14), (12, 11), (13, 17), (14, -1), (15, -1), (16, 10), (17, 11), (18, -1)]

g.add_edges_from(edgelist)
p=nx.drawing.nx_pydot.to_pydot(g)
p.write_png(‘pydot_Tree.png‘)

the plot result:
技术分享图片

Draw graph(network) with nx_pydot in networkx

原文:https://www.cnblogs.com/sonictl/p/13364417.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!