vertex_size with GraphView

Hi, I think I've found a bug. Basically I'm trying to use vertex_size with
graph_draw() using a GraphView, but it only seems to work with the original

import graph_tool.all as gt
from numpy.random import randint, random
from itertools import izip

N = 50
g = gt.Graph()

# insert some random links
for s,t in izip(randint(0, N, N), randint(0, N, N)):
    g.add_edge(g.vertex(s), g.vertex(t))

vsize = g.new_vertex_property('float')
vsize.a = random(N)**2
vsize = gt.prop_to_size(vsize)
vsize.a *= 10

# this works
gt.graph_draw(g, vertex_size=vsize)

gv = gt.GraphView(g, vfilt=lambda v:v.out_degree()>1)
# this doesn't
gt.graph_draw(gv, vertex_size=vsize)

The traceback is:

/usr/lib/python2.7/dist-packages/graph_tool/draw/cairo_draw.pyc in
get_bb(g, pos, size, pen_width, size_scale, text, font_family, font_size,
   1279 x_range = [pos_x.fa.min(), pos_x.fa.max()]
   1280 y_range = [pos_y.fa.min(), pos_y.fa.max()]
-> 1281 x_delta = [x_range[0] - (pos_x.fa - delta).min(),
   1282 (pos_x.fa + delta).max() - x_range[1]]
   1283 y_delta = [y_range[0] - (pos_y.fa - delta).min(),

ValueError: operands could not be broadcast together with shapes (13,)


attachment.html (3.1 KB)

It is not a bug. The "vsize" property belongs to the original graph, and
hence will have a different number of elements. You need to do:

      vsize = gv.own_property(vsize)

before calling graph_draw(). Note that, like GraphView, this does not
duplicate the property map; it is only a "view".


Aha, thanks. That was not clear from the docs. I was confused because some
'original' property maps do seem to work when drawing a graph view, e.g.

attachment.html (3 KB)