Creating a community graphic in igraph

I was looking for the answer to this question, but could not find a mention, so I decided to publish it here. I am trying to understand if igraph or any packages are an easy way to create a “community graph”, where each node represents a community on the network, and the links are the links between the communities. I can get the community discovery algorithm to work fine in igraph, but I couldn't find a way to collapse the results to just show the connections between each community. Any help would be appreciated.

+8
r social-networking igraph
source share
1 answer

You can simply use the contract.vertices () function. These are groups of vertex contracts at one vertex, essentially the same as you want it. For example.

library(igraph) ## create example graph g1 <- graph.full(5) V(g1)$name <- 1:5 g2 <- graph.full(5) V(g2)$name <- 6:10 g3 <- graph.ring(5) V(g3)$name <- 11:15 g <- g1 %du% g2 %du% g3 + edge('1', '6') + edge('1', '11') ## Community structure fc <- fastgreedy.community(g) ## Create community graph, edge weights are the number of edges cg <- contract.vertices(g, membership(fc)) E(cg)$weight <- 1 cg2 <- simplify(cg, remove.loops=FALSE) ## Plot the community graph plot(cg2, edge.label=E(cg2)$weight, margin=.5, layout=layout.circle) 
+19
source share

All Articles