After using community_structure(), each vertex in the graph has a community
property.
However, how to extract some certain communities from this graph ?
Such as, the graph G contains communities {1,2,3,4,5}, now, I hope to get
and save a sub-graph which contains the vertices and their edge in
communities {2,4,5} of G ?
Is there any continent and fast function or algorithm in graph_tool to solve
this problem ?
The reason is that the filtered graph is just like the unfiltered graph,
but with a filter on top. Filtering is a reversible operation, and can
be removed at any time. If you want to delete the filtered vertices you
can make:
Traceback (most recent call last):
File "/home/workspace/work1/renren.py", line 127, in <module>
find_sub_g()
File "/home/workspace/work1/renren.py", line 97, in find_sub_g
new_g.purge_vertices()
File "/usr/lib/python2.7/dist-packages/graph_tool/__init__.py", line 1850,
in purge_vertices
new_g = Graph(self, prune=(True, False, False))
File "/usr/lib/python2.7/dist-packages/graph_tool/__init__.py", line 1121,
in __init__
vorder.fa = numpy.arange(gv.num_vertices())
File "/usr/lib/python2.7/dist-packages/graph_tool/__init__.py", line 567,
in <lambda>
lambda self, v: self.__get_set_f_array(v, False),
File "/usr/lib/python2.7/dist-packages/graph_tool/__init__.py", line 562,
in __get_set_f_array
a[m] = v
TypeError: array cannot be safely cast to required type
My OS is Ubuntu 12.04 LTS. The graph_tool version is
python-graph-tool/precise uptodate 2.2.26-1.
The same error exists when I build animation_sirs.py at the line 31: g =
Graph(g, prune=True)
Besides, I would like to set the pos of vertices by their communities. Such
as, the vertices in the same community should locate at the near position.
Can I set pos by myself ?
My OS is Ubuntu 12.04 LTS. The graph_tool version is
python-graph-tool/precise uptodate 2.2.26-1.
The same error exists when I build animation_sirs.py at the line 31: g =
Graph(g, prune=True)
This seems to be a bug with the numpy version shipped with Ubuntu
precise. I've tested this here, and everything works fine (i.e. no
errors).
Are you stuck with this Ubuntu version or can you upgrade?
Besides, I would like to set the pos of vertices by their communities. Such
as, the vertices in the same community should locate at the near position.
Can I set pos by myself ?
Of course, pos is a property map like any other. For instance, to change
the position of vertex 42 you do: