1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
| Communitykarate <- cluster_louvain(karate) prettyColors <- c("turquoise4", "azure4", "olivedrab","deeppink4")
communityColors <- prettyColors[membership(Communitykarate)]
edge.weights <- function(community, network, weight.within = 100, weight.between = 1) { bridges <- crossing(communities = community, graph = network) weights <- ifelse(test = bridges, yes = weight.between, no = weight.within) return(weights) } E(karate)$weight <- edge.weights(Communitykarate, karate) karateLayoutA <- layout_with_fr(karate, karateLayout)
set.seed(123) plot(x = Communitykarate, y = karate, edge.width = 1, vertex.size = 10, mark.groups = NULL, layout = karateLayoutA, vertex.label = NA, col = communityColors, c("darkgrey","tomato2")[crossing(Communitykarate, karate) + 1], main = "Communities in Zachary's karate club network (grouped)")
|