reverse_edges: Reverse Edge Direction

View source: R/wrangle-structure.R

reverse_edgesR Documentation

Reverse Edge Direction

Description

Transposes the weight matrix, so every arc runs the other way. TNA users reach for this to look at where transitions came from rather than where they went.

Usage

reverse_edges(x, keep_format = FALSE, directed = NULL)

Arguments

x

Network input.

keep_format

Logical. Return the input format when TRUE.

directed

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

Value

A cograph_network with every edge reversed, or the input format when keep_format = TRUE. An undirected network is returned unchanged, with a cograph_no_effect warning.

See Also

to_directed, to_undirected

Examples

adj <- matrix(c(0, .5, 0,
                0, 0, .7,
                0, 0, 0), 3, 3, byrow = TRUE)
rownames(adj) <- colnames(adj) <- c("A", "B", "C")

reverse_edges(adj)

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