README.md 1023 B

pygraphviz

pip install pygraphviz



import pygraphviz as pgv

G = pgv.AGraph(directed=True, strict=False, nodesep=0, ranksep=1.2, rankdir="TB",
           splines="none", concentrate=True, bgcolor="write",
           compound=True, normalize=False, encoding='UTF-8')

G.add_node(name, label=None, fontname="Times-Roman", fontsize=14,
       shape="ellipse", style="rounded", color="black", fontcolor="black",
       pos="x,y(!)", fixedsize=False, width=1, height=1)

G.add_nodes_from(names, **attr) # 批量添加点,参数同上 


G.add_edge(origin, target, color="black", style="solid", penwidth=1,
           label="", fontname="Times-Roman", fontsize=14, fontcolor="black",
           arrowsize=1, arrowhead="normal", arrowtail="normal", dir="forward")

G.add_nodes_from([[origin_1, target_1],
                  [origin_2, target_2],...], **attr)  # 批量添加线,参数同上

G.layout()
G.draw(file_name, prog="neato")