Learn R Programming

gdistance (version 1.1-2)

resistanceDistance: Resistance distance

Description

Calculates the resistance distance between points.

Usage

resistanceDistance (transition, coords)

Arguments

transition
TransitionLayer object)
coords
point locations coordinates (of SpatialPoints, matrix or numeric class)

Value

  • distance matrix (S3 class dist or matrix)

Details

Resistance distance is equivalent to the expected random-walk commute time between nodes in a graph (Chandra et al. 1997). The function implements the algorithm given by Fouss et al. (2007). Before calculating resistance distances from a TransitionLayer object, see if you need to apply the function geoCorrection.

References

Chandra, A.K., Raghavan, P., Ruzzo, W.L., Smolensy, R. & Tiwari, P. 1996. The electrical resistance of a graph captures its commute and cover times. Computational Complexity, 6(4), 312-340. Fouss, F., Pirotte, A., Renders, J.-M. & Saerens, M. 2007. Random-walk computation of similarities between nodes of a graph with application to collaborative recommendation. IEEE Transactions on Knowledge and Data Engineering, 19(3), 355-369. McRae, B.H. 2006. Isolation by resistance. Evolution 60(8), 1551-1561. http://www.circuitscape.org

See Also

geoCorrection

Examples

Run this code
#Create a new raster and set all its values to unity.
raster <- raster(nrows=18, ncols=36) 
raster <- setValues(raster,rep(1,ncell(raster)))

#Create a Transition object from the raster
tr <- transition(raster,mean,4)

#Create two sets of coordinates
sP1 <- SpatialPoints(cbind(c(65,5,-65),c(55,35,-35)))
sP2 <- SpatialPoints(cbind(c(50,15,-40),c(80,20,-5)))

#Calculate the resistance distance between the points
resistanceDistance(tr,sP1)

Run the code above in your browser using DataLab