Dear R users, I'm trying to construct a distance matrix based on a nb object created by spdep where sites must have a larger influence in one direction then in the other. Here is an example to better illustrate what I need: Let say I have the following Gabriel connection network library(spdep) library(ade4) data(orbatid) nbgab<-graph2nb(gabrielneigh(as.matrix(oribatid$xy))) plot(nbgab,oribatid$xy) text(oribatid$xy,as.character(1:70),pos=1) # site number arrows(-0.3,0,-0.3,10) # gradient direction In that example, site 1 shouldn't influence site 2 (so it should have a distance if 0 in the distance matrix). However site 1 should influence site 7 (1 in the distance matrix), it should also influence site 12 and 10 (2 in the distance matrix), and site 13,14,17 and 20 (3 in the distance matrix) and so on for every site. Also, the smallest number of "jumps" from one site to the other has to be considered (e.g. 1 to 20 can be connected through 3 links (1 -> 7 -> 10 -> 20) or through 4 links (1 -> 7 -> 12 -> 13 -> 20)). Considering the gradient, it has to be noted that the distance matrix will be asymmetric (e.g. site 7 doesn't influence site 1). This needs to be done for various connection network, going from regular grid (rook connections) to networks such as the one presented above. Can it be done ? If it can, I would be very happy for some one to give me a hand. And if it has already been done I would be glad to be pointed in the right direction. Thanks in advance !! Guillaume Blanchet