Fast creation of LFR Benchmark graphs in R

[This article was first published on schochastics, 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.

Almost a year ago, I introduced my most recent network related R packages netUtils. The package is meant as a catch-all package where I gather network analytic methods that haven’t yet been implemented in R and may not deserve there own package. Between its initial release and today, I add the infamous LFR-Benchmark graphs to the package. The LFR (Lancichinetti-Fortunato-Radicchi) Benchmark is a widely used graph model for studying community structure. It generates graphs with known community assignments, allowing researchers to evaluate the performance of community detection algorithms. The model has a large set of parameters which allow to create very diverse but realistic graphs which pose tougher challenges for clustering algorithms as other models.

I implemented the algorithm in plain R and it was horribly slow. I did find an implementation in C++ in October 2022 but it took me another 8 months to finally sit down and integrate the code into the package. To obtain the sped up version you need to have netUtils with version greater than 0.8.1 (The upgraded package 0.8.2 was submitted to CRAN on 2023-6-2028).

The code below was running for minutes in base R but now, we can get an instantiation of an LFR graph in a blink of an eye.

g <- sample_lfr(n = 1000,average_degree = 15, max_degree = 50, 
                min_community = 20, max_community = 50,mu = 0.01)

Happy clustering!

To leave a comment for the author, please follow the link and comment on their blog: schochastics.

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.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)