Reference: https://assemblingnetwork.wordpress.com/2013/05/29/network-basics-with-r-and-igraph-part-i-of-iii/
#load the library
library(igraph)
# following code builds network with two nodes, with A related to B
graph.twonodesonelink<-graph.formula
(A-+B)
#following code helps you visualize the graph
plot.igraph(graph.twonodesonelink)
#following code plots graph with four nodes
graph.testchain<-graph.formula
(A-+C,B-+C,C-+D)
# following code plots the above graph:
plot.igraph
(graph.testchain)
#Read data – first two columns spanning rows 1814 to 1906 from the following excel file # which is stored in the R working directory
otago.graph.part1<-graph.edgelist(as.matrix(otago.links.data[1814:1906,1:2]))
# Get the network web into matrix form
otago.adjmatrix.part1<-
get.adjacency
(otago.graph.part1,sparse=F)
# Get the basic network indices from the matrices with GenInd()
ind.otago.part1<-
GenInd
(otago.adjmatrix.part1)
#plot the above matrix
par
(mar=
c
(.1,.1,.1,.1))
plot.igraph
otago.graph.part1,vertex.label=
NA
,vertex.size=3,edge.arrow.size=.25,layout=layout.circle)