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. For a directed input, "mutual" gives both arcs of a pair the larger of the two weights, and "arbitrary" drops every arc from a higher to a lower index.

keep_format

Logical. If TRUE, a matrix, igraph, statnet network or tna input is returned in its own format. An edge-list data frame or a qgraph object is returned as a cograph_network with a cograph_no_format_roundtrip warning. Default FALSE returns a cograph_network.

directed

Logical or NULL. Directedness used to read the input. NULL (default) detects it from the input.

Value

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

See Also

to_undirected, reverse_edges

Examples

to_directed(to_undirected(regulation_net))

cograph documentation built on Nov. 19, 2026, 5:07 p.m.