library(igraph) # read the graph from a file # here we have the network stored in an edgelist g <- read.graph("/Users/kpele/Documents/Teaching/i3-NetScience/sample_net",format="ncol") # visualize the network plot(g) # compute the degree of every node in the network degree(g) # compute the normalized frequency of every degree in the network degree.distribution(g) # plot the degree distribution barplot(degree.distribution(g),names=c(0,1,2,3,4),xlab="Node degree",ylab="Normalized frequency") # examine whether the network is connected, i.e., there is only one connected component is.connected(g) # find the components of the network clusters(g) # find the average path length average.path.length(g) # find the shortest path length between every pair of nodes shortest.paths(g) # find the actual shortest paths from node "from" to all the other nodes in the network get.shortest.paths(g,from=V(g)[1]) # find the local clustering coefficient of each node in the network transitivity(g,type="local")