View source: R/network-utils.R
| select_neighbors | R Documentation |
Select nodes within a specified distance from focal nodes.
select_neighbors(
x,
of,
order = 1L,
...,
.keep_edges = c("internal", "none"),
keep_format = FALSE,
directed = NULL
)
x |
Network input. |
of |
Character or integer. Focal node(s) by name or index. |
order |
Integer. Neighborhood order (1 = direct neighbors). Default 1. |
... |
Additional filter expressions to apply after neighborhood selection. |
.keep_edges |
How to handle edges. Default "internal". |
keep_format |
Logical. Keep input format? Default FALSE. |
directed |
Logical or NULL. Auto-detect if NULL. |
A cograph_network with nodes in the neighborhood.
select_nodes, select_component
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")
# Direct neighbors of A
select_neighbors(adj, of = "A")
# Neighbors up to 2 hops
select_neighbors(adj, of = "A", order = 2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.