Hi everyone, I cannot find a simple way to plot a network with all nodes on a circle. So I develop this method (which do the job): def ring_layout(g,radius = 100): N = g.num_vertices() pos = g.new_vertex_property("vector<double>") for v in g.vertices(): i = g.vertex_index[v] posv = Vector_double() posv.append(radius*cos(2.*i*pi/N)) posv.append(radius*sin(2.*i*pi/N)) pos[v] = posv return pos Is there a simpler way to do this in graph_tool? Is there something that I am missing? Thanks. Best regards, Julien -- View this message in context: http://main-discussion-list-for-the-graph-tool-project.982480.n3.nabble.com/... Sent from the Main discussion list for the graph-tool project mailing list archive at Nabble.com.
On 01/15/2014 02:17 PM, julien.siebert wrote:
Hi everyone,
I cannot find a simple way to plot a network with all nodes on a circle. So I develop this method (which do the job):
def ring_layout(g,radius = 100): N = g.num_vertices() pos = g.new_vertex_property("vector<double>") for v in g.vertices(): i = g.vertex_index[v] posv = Vector_double() posv.append(radius*cos(2.*i*pi/N)) posv.append(radius*sin(2.*i*pi/N)) pos[v] = posv return pos
Is there a simpler way to do this in graph_tool? Is there something that I am missing?
Seems OK. There is no built-in ring layout in graph-tool, so you have to implement it yourself. Note that you do not need to work with Vector_double types like you did, since these are only meant to be used internally by the library. Instead, you should use any regular python sequence, such as lists or numpy arrays. I.e. pos[v] = [radius*cos(2.*i*pi/N), radius*sin(2.*i*pi/N)] would do just fine. Best, Tiago -- Tiago de Paula Peixoto <tiago@skewed.de>
participants (2)
-
julien.siebert -
Tiago de Paula Peixoto