# NOT RUN {
library(igraph)
set.seed(1284)
#generate a random erdos renyi graph with 100 nodes and 150 edges
g <- erdos.renyi.game(n=100, p.or.m = 150, type = "gnm" )
#count the number of components
components(g)$no
#remove all but the largest component
g2 <-remove_small_components(g)
#Now there is only 1 component
igraph::components(g2)$no
# }
Run the code above in your browser using DataLab