sbn_to_mtx.Rd
Convert a downstream directed SBN to various adjacency or distance matrix formats.
sbn_to_mtx(
g,
method = c("dwn_mtx", "undir_mtx", "up_mtx", "n2n_dist_up", "n2n_dist_dwn",
"n2n_dist_undir"),
unconnected = Inf,
weights = NULL
)
a river network as an igraph object. Must be a downstream directed graph.
one of "dwn_mtx", an adjacency matrix for a downstream directed SBN, "up_mtx", an adjacency matrix for a upstream directed SBN, "undir_mtx", an adjacency matrix for a undirected SBN, "n2n_dist_up", "n2n_dist_dwn" or "n2n_dist_undir", an adjacency matrix of upstream, downstream or undirected node to node distances.
when generating node-to-node distance matrices, what value should be used for unconnected elements. For example, in a downstream directed network, all upstream links are considered unconnected. Default value is Inf
but other options are possible, such as NA
or 0
.
passed to igraph::shortest.paths()
. Possibly a numeric vector giving edge weights. If this is NULL
and the graph has a weight edge attribute, then the attribute is used. If this is NA
then no weights are used (even if the graph has a weight attribute).
An adjacency or distance matrix.
g <- sbn_create(10, 0.7)
sbn_to_mtx(g, method = "dwn_mtx")
#> [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
#> [1,] 0 0 0 0 0 0 0 0 0 0
#> [2,] 1 0 0 0 0 0 0 0 0 0
#> [3,] 1 0 0 0 0 0 0 0 0 0
#> [4,] 0 1 0 0 0 0 0 0 0 0
#> [5,] 0 1 0 0 0 0 0 0 0 0
#> [6,] 0 0 1 0 0 0 0 0 0 0
#> [7,] 0 0 0 1 0 0 0 0 0 0
#> [8,] 0 0 0 0 1 0 0 0 0 0
#> [9,] 0 0 0 0 0 1 0 0 0 0
#> [10,] 0 0 0 0 0 1 0 0 0 0