View source: R/wrangle-structure.R
| remove_isolates | R Documentation |
Drops every node with no edges. Filtering edges deliberately keeps nodes
(see filter_edges), so this is the explicit way to prune the
isolates a filter left behind.
remove_isolates(x, keep_format = FALSE, directed = NULL)
x |
Network input: cograph_network, matrix, igraph, network, tna, or an edge-list data frame. |
keep_format |
Logical. If TRUE, matrix, igraph, statnet network and tna inputs are returned in that format. Default FALSE returns a cograph_network. |
directed |
Logical or NULL. If NULL (default), auto-detect. |
A cograph_network with the isolated nodes removed (or the
input format when keep_format = TRUE). Node order is otherwise
preserved and edge indices are remapped to the new node numbering.
filter_edges, split_components,
filter_nodes
adj <- matrix(0, 4, 4, dimnames = list(LETTERS[1:4], LETTERS[1:4]))
adj["A", "B"] <- adj["B", "A"] <- 1
# C and D have no edges
remove_isolates(adj)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.