笔画画

演示如何使用pygraphviz a graph类的接口绘制图形的示例。

另请参见pygraphviz文档和示例,网址为http://pygraphviz.github.io。/

# Author: Aric Hagberg (hagberg@lanl.gov)

#    Copyright (C) 2006-2019 by
#    Aric Hagberg <hagberg@lanl.gov>
#    Dan Schult <dschult@colgate.edu>
#    Pieter Swart <swart@lanl.gov>
#    All rights reserved.
#    BSD license.

import networkx as nx

# plain graph

G = nx.complete_graph(5)   # start with K5 in networkx
A = nx.nx_agraph.to_agraph(G)        # convert to a graphviz graph
A.layout()            # neato layout
A.draw("k5.ps")       # write postscript in k5.ps with neato layout

脚本的总运行时间: (0分0.118秒)

Gallery generated by Sphinx-Gallery