Calculates the shortest path between all pairs of vertices in a network. This uses the power matrices to do so, which makes it efficient only for small networks.

geodesic(x, force = FALSE, ...)

geodesita(x, force = FALSE, ...)

# S3 method for matrix
geodesic(x, force = FALSE, simplify = FALSE, ...)

# S3 method for network
geodesic(x, force = FALSE, simplify = FALSE, ...)

Arguments

x

Either a list of networks (or square integer matrices), an integer matrix, a network, or an ergmito.

force

Logical scalar. If force = FALSE (the default) and nvertex(x) > 100 it returns with an error. To force computation use force = TRUE.

...

Further arguments passed to the method.

simplify

Logical scalar. When TRUE it returns a matrix, otherwise, a list of length nnets(x).

Examples

data(fivenets) geodesic(fivenets)
#> [[1]] #> [,1] [,2] [,3] [,4] #> [1,] 0 NA NA NA #> [2,] 1 0 NA 1 #> [3,] NA NA 0 NA #> [4,] NA NA NA 0 #> #> [[2]] #> [,1] [,2] [,3] [,4] #> [1,] 0 2 1 1 #> [2,] 1 0 2 2 #> [3,] 1 1 0 1 #> [4,] 2 2 1 0 #> #> [[3]] #> [,1] [,2] [,3] [,4] #> [1,] 0 2 1 3 #> [2,] NA 0 NA 1 #> [3,] 1 1 0 2 #> [4,] NA NA NA 0 #> #> [[4]] #> [,1] [,2] [,3] [,4] #> [1,] 0 1 1 1 #> [2,] NA 0 1 1 #> [3,] NA NA 0 NA #> [4,] NA NA NA 0 #> #> [[5]] #> [,1] [,2] [,3] [,4] #> [1,] 0 NA NA NA #> [2,] NA 0 NA NA #> [3,] 1 NA 0 1 #> [4,] NA NA NA 0 #>
# Comparing with sna if (require("sna")) { net0 <- fivenets[[1]] net <- network::network(fivenets[[1]]) benchmarkito( ergmito = ergmito::geodesic(net0), sna = sna::geodist(net), times = 1000 ) }
#> Loading required package: sna
#> Loading required package: statnet.common
#> #> Attaching package: ‘statnet.common’
#> The following object is masked from ‘package:base’: #> #> order
#> sna: Tools for Social Network Analysis #> Version 2.5 created on 2019-12-09. #> copyright (c) 2005, Carter T. Butts, University of California-Irvine #> For citation information, type citation("sna"). #> Type help(package="sna") to get started.
#> Error in as.edgelist.sna(dat): object 'net' not found