Last active
May 24, 2018 15:11
-
-
Save gweissman/9b25f79fabac7803462138b7dd533ca8 to your computer and use it in GitHub Desktop.
How to highlight the giant component of a graph using igraph
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# highlight communities and clusters in an igraph plot | |
library(igraph) | |
g <- erdos.renyi.game(50, .02) | |
# plot regular | |
plot(g) | |
# get the components of the graph | |
comps <- components(g) | |
# which is biggest? | |
giant_id <- which.max(comps$csize) | |
# now plot again marking the largest component | |
plot(g, mark.groups = list(comps$membership == giant_id), mark.col = 'green') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment