to_directed: Convert an Undirected Network to Directed

View source: R/wrangle-structure.R

to_directedR Documentation

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
)

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.

Value

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

See Also

to_undirected, reverse_edges

Examples

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

cograph documentation built on Sept. 30, 2026, 5:08 p.m.