On 07.08.2016 07:08, Enigma Fish wrote:
> Dear graph-tool owner and subscribers,
>
> I would like to draw the largest component of a directed graph g, where the
> vertex size = the out degree.
> Here's my code:
> g = load_graph(inFile)
> g=GraphView(g,vfilt=label_largest_component(g, directed=False))
> g.purge_vertices()
> deg =g.degree_property_map("out")
> deg.a = (sqrt(deg.a) * 0.5 + 0.4)+1
> graph_draw(g, vertex_size=deg,output="test1.pdf")
>
> But I keep getting the following error whenever I try to draw it:
> Traceback (most recent call last):
> File "/Users/enigmaFish/PycharmProjects/project/paint.py", line 49, in
> <module>
> graph_draw(g, vertex_size=deg,output="test1.pdf")
> File
> "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/graph_tool/draw/cairo_draw.py",
> line 1138, in graph_draw
> pad, cr)
> File
> "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/graph_tool/draw/cairo_draw.py",
> line 1312, in fit_to_view
> font_size, cr)
> File
> "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/graph_tool/draw/cairo_draw.py",
> line 1285, in get_bb
> x_delta = [x_range[0] - (pos_x.fa - delta).min(),
> ValueError: operands could not be broadcast together with shapes (47579,)
> (10438,)
>
> Note that g is <Graph object, directed, with 47579 vertices and 38781 edges
> at 0x1292a15d0>
> Upon filtering, it becomes <GraphView object, directed, with 10438 vertices
> and 12388 edges, edges filtered by (<PropertyMap object with key type 'Edge'
> and value type 'bool', for Graph 0x1292bcd10, at 0x1292cf5d0>, False),
> vertices filtered by (<PropertyMap object with key type 'Vertex' and value
> type 'bool', for Graph 0x1292bcd10, at 0x1292cf110>, False) at 0x1292bcd10>
This is a bug. I will fix it soon.
In the meantime, a simple workaround is to replace
g.purge_vertices()
with
g = Graph(g, prune=True)
Best,
Tiago
--
Tiago de Paula Peixoto <[email protected]>
signature.asc
Description: OpenPGP digital signature
_______________________________________________ graph-tool mailing list [email protected] https://lists.skewed.de/mailman/listinfo/graph-tool
