Search code examples
pythongraphgraph-tool

AttributeError when trying to do a block partition with graph-tool


I am getting this error:

AttributeError: 'list' object has no attribute 'clear'

when trying to execute the example at this page

block partition example

The example is:

>>> g = gt.collection.data["power"]
>>> bstack, mdl = gt.minimize_nested_blockmodel_dl(g, deg_corr=True)
>>> t = gt.get_hierarchy_tree(bstack)[0]
>>> tpos = pos = gt.radial_tree_layout(t, t.vertex(t.num_vertices() - 1), weighted=True)
>>> cts = gt.get_hierarchy_control_points(g, t, tpos)
>>> pos = g.own_property(tpos)
>>> b = bstack[0].vp["b"]
>>> gt.graph_draw(g, pos=pos, vertex_fill_color=b, vertex_shape=b, edge_control_points=cts,
...               edge_color=[0, 0, 0, 0.3], vertex_anchor=0, output="power_nested_mdl.pdf")
<...>

and it gives me the exception when running the line:

>>> bstack, mdl = gt.minimize_nested_blockmodel_dl(g, deg_corr=True)

Any clue?

Thanks


Solution

  • list.clear() is not in Python 2, only in Python 3. The example runs without problem in Python 3.

    Anyway, graph-tool is supposed to work on Python 2.7 and above, so this might as well be reported as a bug.