View source: R/wrangle-structure.R
| to_undirected | R Documentation |
Collapses each pair of opposite arcs into one undirected edge. The
counterpart of igraph::as_undirected() and tidygraph's
to_undirected().
to_undirected(
x,
method = c("max", "sum", "mean", "min", "mutual"),
keep_format = FALSE,
directed = NULL
)
x |
Network input. |
method |
How to combine |
keep_format |
Logical. Return the input format when TRUE. |
directed |
Logical or NULL. Directedness to read the input with. |
An undirected cograph_network, or the input format when
keep_format = TRUE. Zero is how this representation stores "no
edge", so any pair whose combined weight is exactly zero disappears: every
unreciprocated arc under method = "mutual", and a cancelling pair
under "sum". A cograph_edges_dropped warning says how
many.
to_directed, symmetrize
adj <- matrix(c(0, .5, 0,
.2, 0, .7,
0, 0, 0), 3, 3, byrow = TRUE)
rownames(adj) <- colnames(adj) <- c("A", "B", "C")
to_undirected(adj, method = "sum")
to_undirected(adj, method = "mutual")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.