In a directed network, nodes are linked via other nodes if they have common neighbor by in or out direction. This principle is the base of shared nearest neigbor (SNN) projection. For example in the (in direction) projection of traveling network, two cities are connected if one traveler goes to the same city than from another city. And in the other (out direction) projected network two destination cities are connected if from a city one traveler goes to a city and another one travels to the other. If there are more than one travels are between two cities than the network is weighted. In the projected case the edge weight of projected network is the minimum of common edges.
The algorithm operates with edge list of a network, which is more efficient than with large and sparse matrix.
Projected network shows similarity by in/out travels of nodes which can be used for different aims.
library("igraph")
library("reshape2")
library("dplyr")
library("data.table")A <- matrix(c(0 , 2 , 0 , 0 , 0 , 2 , 1 ,
0 , 0 , 0 , 0 , 2 , 1 , 4 ,
0 , 0 , 0 , 0 , 3 , 2 , 2 ,
0 , 0 , 0 , 0 , 0 , 0 , 0 ,
2 , 2 , 3 , 5 , 0 , 0 , 0 ,
6 , 4 , 3 , 2 , 0 , 0 , 0 ,
0 , 3 , 0 , 1 , 0 , 0 , 0 ),
nrow=7, ncol=7, byrow = T)
rownames(A) <- paste("x", 1:7, sep="")
colnames(A) <- paste("x", 1:7, sep="")g <- graph.adjacency(A, mode="directed", weighted = T)plot(g, edge.color="gray60", edge.width=E(g)$weight, vertex.size=20, vertex.label.cex=0.9, margin=0, asp=0.8, edge.curved=TRUE)