Plot communities with igraph

3k views Asked by At

I want to create a graph plot with each community of nodes been covered by some background color, similar to the graph by the following code

karate <- graph.famous("Zachary")
wc <- walktrap.community(karate)
modularity(wc)
membership(wc)
plot(wc, karate)

But different from this approach, I want to: (1) group the nodes by myself, instead of resulting from community detection algorithm. I achieved this by wc$membership <- some_vector; (2) plot such graph possibly with overlap between communities, then how can I assign one node to multiple communities?

1

There are 1 answers

0
Tamás On

Plot the graph itself instead of the community structure, and use an appropriately constructed mark.groups argument to plot() to tell igraph which groups should be enclosed by the same group. The following quote is from the manual page of plot.igraph:

mark.groups: A list of vertex id vectors. It is interpreted as a set of vertex groups. Each vertex group is highlighted, by plotting a colored smoothed polygon around and "under" it.