On 06/01/2014 12:33 AM, jmazel wrote:
Hi I am trying to extract communities of a graph with the graph_tool.community.minimize_blockmodel_dl function and by following the example on this page: http://graph-tool.skewed.de/static/doc/community.html. Unfortunately, I get an error:
Traceback (most recent call last): File "community.py", line 7, in <module> graph_draw(g, pos=g.vp["pos"], vertex_fill_color=b, vertex_shape=b, output="output_blocks_mdl.pdf") File "/usr/lib/python2.7/dist-packages/graph_tool/__init__.py", line 995, in __getitem__ val = self.get_func(self.g, key) File "/usr/lib/python2.7/dist-packages/graph_tool/__init__.py", line 1458, in <lambda> lambda g, k: g.__properties[("v", k)], KeyError: ('v', 'pos')
Here is my code: from graph_tool.all import * g = load_graph("graph.dot") b, mdl = minimize_blockmodel_dl(g) graph_draw(g, pos=g.vp["pos"], vertex_fill_color=b, vertex_shape=b, output="output_blocks_mdl.pdf")
Your graph does not have a "pos" vertex property map, which is passed to the graph_draw() function in the example above. You should just use: graph_draw(g, vertex_fill_color=b, vertex_shape=b, output="output_blocks_mdl.pdf") Best, Tiago -- Tiago de Paula Peixoto <tiago@skewed.de>