Im trying to set text in different vertexs and draw them, but I don't know how to make it. I searched graph_tool documentaction but I can't find out how to make it because examples there are so confused...
My code is:
from graph_tool.all import *
g = Graph()
g.add_vertex()
// How to something like: g.vertex(0).text = "A"
g.add_vertex()
// How to something like: g.vertex(1).text = "B"
g.add_edge(g.vertex(0),g.vertex(1))
// And how to use it instead of vertex_index
graph_draw(g, vertex_text=g.vertex_index, vertex_font_size=18, output_size=(200, 200), output="test.png")
Waiting for any clues
#!/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")
This should really be on the graph-tools website intro.
If you can find out how to set an edge length I'd like to know.
#!/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")
This is what I'm using instead, because I can manipulate the widths... It complains if I try to set the length.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With