R script for community detection based on iGraph