#!/usr/bin/python3
from graph_tool.all import *
g = Graph()
v1 = g.add_vertex()
v2 = g.add_vertex()
e = g.add_edge(v1, v2)
v_prop = g.new_vertex_property("string")
v_prop[v1] = 'foo'
v_prop[v2] = 'bar'
e_prop = g.new_edge_property("string")
e_prop[e] = 'e1'
graph_draw(g, vertex_text=v_prop,edge_text=e_prop, vertex_font_size=18, output_size=(200, 200), output="two-nodes.png")
这真的应该在图形工具网站介绍上。
如果你能找到我想知道的如何设置边长。
#!/usr/bin/python3
from graph_tool.all import *
g = Graph()
v1 = g.add_vertex()
v2 = g.add_vertex()
v3 = g.add_vertex()
e2 = g.add_edge(v1, v2)
e1 = g.add_edge(v1, v3)
v_prop = g.new_vertex_property("string")
v_prop[v1] = 'foo'
v_prop[v2] = 'bar'
v_prop[v3] = 'baz'
e_prop = g.new_edge_property("string")
e_prop[e1] = 'edge 1'
e_prop[e2] = 'edge 2'
e_len = g.new_edge_property("double")
e_len[e1] = 10
e_len[e2] = 20
graph_draw(g, vertex_text=v_prop, edge_text=e_prop, edge_pen_width = e_len, vertex_font_size=18, output_size=(800, 800), output="two-nodes.png")
这就是我正在使用的,因为我可以操纵宽度......如果我尝试设置长度,它会抱怨。