sbn_to_mtx: Convert network to various adjacency/distance matrix formats

Description Usage Arguments Value Examples

View source: R/sbn_to_mtx.R

Description

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

Usage

1
2
3
4
5
6
7
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

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

flee598/SBN documentation built on Jan. 24, 2022, 11:37 p.m.