On 11/08/2013 09:29 PM, vcongz wrote:
> 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 ?

You can use a graph filter:

    http://graph-tool.skewed.de/static/doc/quickstart.html#graph-filtering

If 'c' is a property map with your community labels, you can extract the
community subgraph with:

   u = GraphView(g, vfilt=lambda v: c[v] in [2, 4, 5])

The graph view u now contains only the vertices belonging to communities [2,
4, 5].

Cheers,
Tiago


-- 
Tiago de Paula Peixoto <[email protected]>

Attachment: signature.asc
Description: OpenPGP digital signature

_______________________________________________
graph-tool mailing list
[email protected]
http://lists.skewed.de/mailman/listinfo/graph-tool

Reply via email to