#https://igraph.org/r/doc/igraph.pdf
#Ognyanova, K. (2016) Network analysis with R and igraph: NetSci X Tutorial. Retrieved from www.kateto.net/networks-r-igraph.

install.packages("igraph") 
library(igraph)

#full graph
fg <- make_full_graph(40)
plot(fg, vertex.size=10, vertex.label=NA)

#simple star
st <- make_star(40)
plot(st, vertex.size=10, vertex.label=NA) 

#tree
tr <- make_tree(40, children = 3, mode = "undirected")
plot(tr, vertex.size=10, vertex.label=NA) 

#ring
rn <- make_ring(40)
plot(rn, vertex.size=10, vertex.label=NA)

#Erdos-Renyi random graph model
er <- sample_gnm(n=100, m=40) 
plot(er, vertex.size=6, vertex.label=NA)  

#Watts-Strogatz small-world model
sw <- sample_smallworld(dim=2, size=10, nei=1, p=0.1)
plot(sw, vertex.size=6, vertex.label=NA, layout=layout_in_circle)

#Barabasi-Albert preferential attachment model for scale-free graphs
 ba <-  sample_pa(n=100, power=1, m=1,  directed=F)
 plot(ba, vertex.size=6, vertex.label=NA)


 

Top