Quick Retrieve on Google     Quick Retrieve on Bing

Combine Art and Sciences

Blogs transfered from: blog.csdn.net/sonictl

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

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:

posted on 2020-07-23 09:23  sonictl  阅读(210)  评论(0编辑  收藏  举报