Learn R Programming

cograph (version 2.7.2)

bind_networks: Combine Two Networks

Description

Aligns two networks on node labels and combines their edges.

Usage

bind_networks(
  x,
  y,
  method = c("union", "intersection", "difference"),
  weight = c("sum", "mean", "max", "min", "first"),
  keep_format = FALSE,
  directed = NULL
)

Value

A cograph_network over the combined node set, or x's format when keep_format = TRUE. Nodes are ordered with x's first, then any node only y has.

Arguments

x, y

Network inputs.

method

How to combine the edge sets:

"union"

(default) every edge of either network, over the union of the node sets

"intersection"

only edges present in both, over the nodes common to both

"difference"

edges of x that are not in y, over the nodes of x

weight

How to combine the weights of an edge present in both: "sum" (default), "mean", "max", "min", or "first" (keep x's weight).

keep_format

Logical. Return x's format when TRUE.

directed

Logical or NULL. If NULL (default), the result is directed when either input is.

See Also

add_edges, plot_difference

Examples

Run this code
a <- matrix(0, 3, 3, dimnames = list(c("A", "B", "C"), c("A", "B", "C")))
a["A", "B"] <- a["B", "A"] <- 1
b <- matrix(0, 3, 3, dimnames = list(c("B", "C", "D"), c("B", "C", "D")))
b["B", "C"] <- b["C", "B"] <- 2

bind_networks(a, b)
bind_networks(a, b, method = "difference")

Run the code above in your browser using DataLab