% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/network-utils.R
\name{select_component}
\alias{select_component}
\title{Select Connected Component}
\usage{
select_component(
  x,
  which = "largest",
  ...,
  .keep_edges = c("internal", "none"),
  keep_format = FALSE,
  directed = NULL
)
}
\arguments{
\item{x}{Network input.}

\item{which}{Component selection:
\describe{
\item{\code{"largest"}}{(default) The largest connected component}
\item{Integer}{Component by ID}
\item{Character}{Component containing the named node}
}}

\item{...}{Additional filter expressions to apply after component 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 selected component.
}
\description{
Select nodes belonging to a specific connected component.
}
\examples{
# Create disconnected network
adj <- matrix(0, 6, 6)
adj[1, 2] <- adj[2, 1] <- 1
adj[1, 3] <- adj[3, 1] <- 1
adj[4, 5] <- adj[5, 4] <- 1
adj[5, 6] <- adj[6, 5] <- 1
adj[4, 6] <- adj[6, 4] <- 1
rownames(adj) <- colnames(adj) <- LETTERS[1:6]

# Largest component
select_component(adj, which = "largest")

# Component containing node "A"
select_component(adj, which = "A")
}
\seealso{
\code{\link{select_nodes}}, \code{\link{select_neighbors}}
}
