#A weighted network with heterogeneous (i.e. multiscale) weights
W <- matrix(c(0,10,10,10,10,75,0,0,0,0,
10,0,1,1,1,0,0,0,0,0,
10,1,0,1,1,0,0,0,0,0,
10,1,1,0,1,0,0,0,0,0,
10,1,1,1,0,0,0,0,0,0,
75,0,0,0,0,0,100,100,100,100,
0,0,0,0,0,100,0,10,10,10,
0,0,0,0,0,100,10,0,10,10,
0,0,0,0,0,100,10,10,0,10,
0,0,0,0,0,100,10,10,10,0),10)
W <- igraph::graph_from_adjacency_matrix(W, mode = "undirected", weighted = TRUE)
plot(W, edge.width = sqrt(igraph::E(W)$weight)) #A stronger clique & a weaker clique
mean_weight <- mean(igraph::E(W)$weight) #Find average edge weight
bb <- backbone_from_weighted(W, model = "global", #A backbone with stronger-than-average edges...
parameter = mean_weight)
plot(bb) #...ignores the weaker clique
bb <- backbone_from_weighted(W, model = "disparity") #A disparity filter backbone...
plot(bb) #...preserves edges at multiple scales
Run the code above in your browser using DataLab