Greetings,
I am using graph-tool to visualise graphs of a tree-type structure where the head node is located at the top and subsequent nodes branch out below. Is there a way to specify this orientation in graph-tool?
The only way I have managed to create a graph of this type is by specifying the position of each node.
g3 = Graph()
g3.set_directed(True)
v1 = g3.add_vertex()
v2 = g3.add_vertex()
v3 = g3.add_vertex()
v4 = g3.add_vertex()
v5 = g3.add_vertex()
e1 = g3.add_edge(v1, v2)
e2 = g3.add_edge(v2, v3)
e3 = g3.add_edge(v3, v4)
e4 = g3.add_edge(v3, v5)
pos = g3.new_vertex_property("vector<double>")
pos[g3.vertex(0)] = (0, 0)
pos[g3.vertex(1)] = (0, 5)
pos[g3.vertex(2)] = (0, 10)
pos[g3.vertex(3)] = (2.5, 15)
pos[g3.vertex(4)] = (-2.5, 15)
graph_draw(g3, pos=pos, vertex_text=g3.vertex_index, output=path+"test-graph-1.pdf")
Without this, the graph may orient itself differently (horizontally or at an angle) each time the code is run. Is there another way to orientate the graph (top-down) where I do not have to specify every node position?
Thanks.