Contracting and simplifying a network graph
[This article was first published on Revolutions, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
by Andrie de Vries
In a previous post, I used page rank and community structure to create a plot of CRAN. This plot used vibrant colours to allow us to see some of the underlying structure of CRAN.
However, much of this structure was still obfuscated by the amount of detail. Concretely, a large number of dots (packages) made it difficult to easily see the community structure.
Some more investigation followed, and I discovered a few beautiful functions in the igraph package that allows you to contract and simplify a graph:
- The function contract.vertices() merges several vertices into one. By computing the community structure, one can control how this merging happens. At conclusion of the contraction, two vertices can have multiple edges.
- The equivalent step for edges is simplify(). A simplified graph contains only a single edge between two nodes. The simplification step can compute summary statistics for the combined edges, for example the sum of edge weights.
Here is the code:
To leave a comment for the author, please follow the link and comment on their blog: Revolutions.
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.