sbn_to_mtx {SBN}R Documentation

Convert network to various adjacency/distance matrix formats

Description

Convert a downstream directed SBN to various adjacency or distance matrix formats.

Usage

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
)

Arguments

g

a river network as an igraph object. Must be a downstream directed graph.

method

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.

unconnected

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.

weights

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).

Value

An adjacency or distance matrix.

Examples

g <- sbn_create(10, 0.7)
sbn_to_mtx(g, method = "dwn_mtx")


[Package SBN version 1.0.0 Index]