Learn R Programming

tnet (version 3.0.1)

distance_tm: Distance in a two-mode network

Description

The shortest path length, or geodesic distance, between two nodes in a binary network is the minimum number of steps you need to make to go from one of them to the other. See the distance_w-function for more details.

Usage

distance_tm(net, projection.method="sum", gconly=TRUE,subsample=1, seed=NULL)

Arguments

net
A weighted edgelist
projection.method
The way the two-mode network is projected. I believe that the sum method is the best as this takes into consideration the number of events, projects etc that two individuals had contact through. In certain cases, "Newman" might be better. See the projecti
gconly
logical, whether the function should only be calculated for the giant component. Default is TRUE.
subsample
Whether a only a subset of starting nodes should we used when calculating the measure. This is particularly useful when running out of memory analysing large networks. If it is set to 1, all distances are analysed. If it set to a value below one, this is
seed
If a subset of starting nodes is analysed, by setting this parameter, the results are reproducable.

Value

  • Returns a distance matrix.

References

http://toreopsahl.com/2009/01/09/average-shortest-distance-in-weighted-networks/

Examples

Run this code
# Load networks
net <- cbind(
 i=c(1,1,2,2,2,3,3,4,5,5,6),
 p=c(1,2,1,3,4,2,3,4,3,5,5),
 w=c(3,5,6,1,2,6,2,1,3,1,2))

# Run the function
distance_tm(net)

Run the code above in your browser using DataLab