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:
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步