Learn R Programming

tnet (version 0.0.6)

distance_w: Distance in a weighted 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. This distance is the quickest connection between nodes when all ties are the same. However, in a weighted network, all ties are not the same.

Usage

distance_w(edgelist, directed=NULL, gconly=TRUE)

Arguments

edgelist
A weighted edgelist
directed
logical, whether the network is directed or undirected. Default is NULL, this means that the function checks whether the edgelist is directed or not.
gconly
logical, whether the function should only be calculated for the giant component. Default is TRUE.

Value

  • Returns a distance matrix.

References

t.opsahl@qmul.ac.uk

Examples

Run this code
## Load sample data
sample <- rbind(
c(1,2,8),
c(1,4,1),
c(2,1,8),
c(2,3,6),
c(3,2,6),
c(3,4,10),
c(4,1,1),
c(4,3,10))

## Run the programme
distance_w(sample)

Run the code above in your browser using DataLab