Learn R Programming

cograph (version 2.7.2)

complement_network: Complement of a Network

Description

Every pair of distinct nodes that is not joined in x is joined in the complement, and vice versa.

Usage

complement_network(
  x,
  weight = 1,
  loops = FALSE,
  keep_format = FALSE,
  directed = NULL
)

Value

A cograph_network holding the complement, or the input format when keep_format = TRUE. Directedness is preserved.

Arguments

x

Network input.

weight

Numeric. Weight to give the new edges. Default 1. Zero is how this representation stores "no edge", so weight = 0 raises a cograph_bad_selection error rather than returning an empty network.

loops

Logical. Include self-loops in the complement. Default FALSE.

keep_format

Logical. Return the input format when TRUE.

directed

Logical or NULL. If NULL (default), auto-detect.

See Also

to_undirected, binarize

Examples

Run this code
adj <- matrix(c(0, 1, 0,
                1, 0, 0,
                0, 0, 0), 3, 3)
rownames(adj) <- colnames(adj) <- c("A", "B", "C")

complement_network(adj)

Run the code above in your browser using DataLab