Problem on community extraction

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")

The dot file looks like this:
graph G {
  167;
  2037;
  717;
  2169;
  166;
  669;
  2541;
  1781;
  1424;
  
  167 -- 166;
  2037 -- 669;
  2037 -- 1424;
  717 -- 166;
  717 -- 167;
  2169 -- 669;
  2169 -- 2037;
  2541 -- 166;
  2541 -- 167;
  2541 -- 669;
  2541 -- 717;
  2541 -- 1781;
  2541 -- 2037;
  
  }

Thnaks for your time.

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

Thanks a lot. :slight_smile:
Johan

2014-06-04 0:49 GMT+09:00 Tiago de Paula Peixoto <tiago(a)skewed.de>:

attachment.html (2.56 KB)