Learn R Programming

cograph (version 2.7.2)

to_directed: Convert an Undirected Network to Directed

Description

Convert an Undirected Network to Directed

Usage

to_directed(
  x,
  mode = c("mutual", "arbitrary"),
  keep_format = FALSE,
  directed = NULL
)

Value

A directed cograph_network, or the input format when keep_format = TRUE.

Arguments

x

Network input.

mode

"mutual" (default) creates an arc in both directions for every undirected edge; "arbitrary" keeps one arc per edge, running from the lower node index to the higher.

keep_format

Logical. Return the input format when TRUE.

directed

Logical or NULL. Directedness to read the input with.

See Also

to_undirected, reverse_edges

Examples

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

to_directed(adj)
to_directed(adj, mode = "arbitrary")

Run the code above in your browser using DataLab