Reputation: 617
I have a graph with the attribute color (numbers) that represents communities obtained with fastgreedy.community
. Some of those communities are just compound by few vertices (5 or less).
1 I would like to remove them, ideally with a function that allow me count the number of vertices per community and remove those vertices associated with small communities. For example, remove vertices of communities smaller than an arbitrary number of vertices. I really have no idea how do this. I will be appreciate any help.
2 I tried to solve this problem in a very simple way, but without success.
I manually identified those small communities and I tried to remove their vertices as I show below:
g2 <-remove.vertex.attribute(g, V(g)[ V(g)[color >13]%--% V(g)[color >13] ])
I just copied this code from other question and it seems that I didn't understand it very well.
Update
Following the advice below, the correct way to do 2 is:
g3 <-delete.vertices(g, V(g)[ V(g)[color >13] ])
However, I would still appreciate if someone help me with the part 1 of my question, as I have to repeat it many time and manually doing it will take me for ever.
Again, any help will be much appreciated
Upvotes: 1
Views: 1157
Reputation: 10826
As its name says, remove.vertex.attribute
removes a vertex attribute. It does not remove vertices. Read this: http://igraph.sourceforge.net/doc/R/graph.structure.html and use delete.vertices
.
Upvotes: 2