View source: R/wrangle-structure.R
| spanning_tree | R Documentation |
Prim's algorithm on each connected component, so a disconnected network yields a spanning forest.
spanning_tree(
x,
weights = c("weight", "none"),
maximum = FALSE,
keep_format = FALSE,
directed = NULL
)
x |
Network input. |
weights |
|
maximum |
Logical. Find the maximum spanning tree instead of the minimum. Default FALSE. Set TRUE when the weights are similarities. |
keep_format |
Logical. Return the input format when TRUE. |
directed |
Logical or NULL. Directedness to read the input with; the tree itself is undirected. |
An undirected cograph_network holding the spanning tree (or
forest), or the input format when keep_format = TRUE. Every node is
kept.
Prim, R. C. (1957). Shortest connection networks and some generalizations. Bell System Technical Journal, 36(6), 1389–1401.
disparity_filter, threshold_edges
adj <- matrix(c(0, .5, .8, 0,
.5, 0, .3, .6,
.8, .3, 0, .4,
0, .6, .4, 0), 4, 4, byrow = TRUE)
rownames(adj) <- colnames(adj) <- c("A", "B", "C", "D")
spanning_tree(adj)
spanning_tree(adj, maximum = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.