% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/network-utils.R
\name{select_top}
\alias{select_top}
\title{Select Top N Nodes by Centrality}
\usage{
select_top(
  x,
  n,
  by = "degree",
  ...,
  .keep_edges = c("internal", "none"),
  keep_format = FALSE,
  directed = NULL
)
}
\arguments{
\item{x}{Network input.}

\item{n}{Integer. Number of top nodes to select.}

\item{by}{Character. Centrality measure for ranking. One of:
\code{"degree"}, \code{"indegree"}, \code{"outdegree"}, \code{"strength"},
\code{"instrength"}, \code{"outstrength"}, \code{"betweenness"},
\code{"closeness"}, \code{"eigenvector"}, \code{"pagerank"},
\code{"hub"}, \code{"authority"}, \code{"coreness"}. Default \code{"degree"}.}

\item{...}{Additional filter expressions to apply.}

\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 the top N nodes.
}
\description{
Select the top N nodes ranked by a centrality measure.
}
\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")

# Top 2 by degree
select_top(adj, n = 2)

# Top 2 by PageRank
select_top(adj, n = 2, by = "pagerank")
}
\seealso{
\code{\link{select_nodes}}, \code{\link{select_component}}
}
