Dyad level indices
d_distance(x, mode = c("all", "out", "in"))
graph object
Character constant, gives whether the shortest paths to or from
the given vertices should be calculated for directed graphs. If out
then the shortest paths from the vertex, if in
then to it will be
considered. If all
, the default, then the corresponding undirected
graph will be used, ie. not directed paths are searched.
This argument is ignored for undirected graphs.
Calculate several dyad level indices.
#
# distance
g <- igraph::make_ring(10)
igraph::distances(g)
#> [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
#> [1,] 0 1 2 3 4 5 4 3 2 1
#> [2,] 1 0 1 2 3 4 5 4 3 2
#> [3,] 2 1 0 1 2 3 4 5 4 3
#> [4,] 3 2 1 0 1 2 3 4 5 4
#> [5,] 4 3 2 1 0 1 2 3 4 5
#> [6,] 5 4 3 2 1 0 1 2 3 4
#> [7,] 4 5 4 3 2 1 0 1 2 3
#> [8,] 3 4 5 4 3 2 1 0 1 2
#> [9,] 2 3 4 5 4 3 2 1 0 1
#> [10,] 1 2 3 4 5 4 3 2 1 0
d_distance(g)
#> [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
#> [1,] 0 1 2 3 4 5 4 3 2 1
#> [2,] 1 0 1 2 3 4 5 4 3 2
#> [3,] 2 1 0 1 2 3 4 5 4 3
#> [4,] 3 2 1 0 1 2 3 4 5 4
#> [5,] 4 3 2 1 0 1 2 3 4 5
#> [6,] 5 4 3 2 1 0 1 2 3 4
#> [7,] 4 5 4 3 2 1 0 1 2 3
#> [8,] 3 4 5 4 3 2 1 0 1 2
#> [9,] 2 3 4 5 4 3 2 1 0 1
#> [10,] 1 2 3 4 5 4 3 2 1 0
d_distance(snafun::to_network(g))
#> 1 2 3 4 5 6 7 8 9 10
#> 1 0 1 2 3 4 5 4 3 2 1
#> 2 1 0 1 2 3 4 5 4 3 2
#> 3 2 1 0 1 2 3 4 5 4 3
#> 4 3 2 1 0 1 2 3 4 5 4
#> 5 4 3 2 1 0 1 2 3 4 5
#> 6 5 4 3 2 1 0 1 2 3 4
#> 7 4 5 4 3 2 1 0 1 2 3
#> 8 3 4 5 4 3 2 1 0 1 2
#> 9 2 3 4 5 4 3 2 1 0 1
#> 10 1 2 3 4 5 4 3 2 1 0
igraph::V(g)$name <- LETTERS[1:10]
igraph::distances(g)
#> A B C D E F G H I J
#> A 0 1 2 3 4 5 4 3 2 1
#> B 1 0 1 2 3 4 5 4 3 2
#> C 2 1 0 1 2 3 4 5 4 3
#> D 3 2 1 0 1 2 3 4 5 4
#> E 4 3 2 1 0 1 2 3 4 5
#> F 5 4 3 2 1 0 1 2 3 4
#> G 4 5 4 3 2 1 0 1 2 3
#> H 3 4 5 4 3 2 1 0 1 2
#> I 2 3 4 5 4 3 2 1 0 1
#> J 1 2 3 4 5 4 3 2 1 0
d_distance(g)
#> A B C D E F G H I J
#> A 0 1 2 3 4 5 4 3 2 1
#> B 1 0 1 2 3 4 5 4 3 2
#> C 2 1 0 1 2 3 4 5 4 3
#> D 3 2 1 0 1 2 3 4 5 4
#> E 4 3 2 1 0 1 2 3 4 5
#> F 5 4 3 2 1 0 1 2 3 4
#> G 4 5 4 3 2 1 0 1 2 3
#> H 3 4 5 4 3 2 1 0 1 2
#> I 2 3 4 5 4 3 2 1 0 1
#> J 1 2 3 4 5 4 3 2 1 0
d_distance(snafun::to_network(g))
#> A B C D E F G H I J
#> A 0 1 2 3 4 5 4 3 2 1
#> B 1 0 1 2 3 4 5 4 3 2
#> C 2 1 0 1 2 3 4 5 4 3
#> D 3 2 1 0 1 2 3 4 5 4
#> E 4 3 2 1 0 1 2 3 4 5
#> F 5 4 3 2 1 0 1 2 3 4
#> G 4 5 4 3 2 1 0 1 2 3
#> H 3 4 5 4 3 2 1 0 1 2
#> I 2 3 4 5 4 3 2 1 0 1
#> J 1 2 3 4 5 4 3 2 1 0