% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/network-utils.R
\name{select_neighbors}
\alias{select_neighbors}
\title{Select Node Neighbors (Ego Network)}
\usage{
select_neighbors(
  x,
  of,
  order = 1L,
  ...,
  .keep_edges = c("internal", "none"),
  keep_format = FALSE,
  directed = NULL
)
}
\arguments{
\item{x}{Network input.}

\item{of}{Character or integer. Focal node(s) by name or index.}

\item{order}{Integer. Neighborhood order (1 = direct neighbors). Default 1.}

\item{...}{Additional filter expressions to apply after neighborhood selection.}

\item{.keep_edges}{How to handle edges. Default "internal".}

\item{keep_format}{Logical. Keep input format? Default FALSE.}

\item{directed}{Logical or NULL. Auto-detect if NULL.}
}
\value{
A cograph_network with nodes in the neighborhood.
}
\description{
Select nodes within a specified distance from focal nodes.
}
\examples{
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)
}
\seealso{
\code{\link{select_nodes}}, \code{\link{select_component}}
}
