% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/ego.R
\name{ego_networks}
\alias{ego_networks}
\title{Ego-Network Metrics}
\usage{
ego_networks(
  x,
  nodes = NULL,
  order = 1,
  mode = c("all", "out", "in"),
  directed = NULL,
  ...
)
}
\arguments{
\item{x}{Network input: matrix, igraph, network, cograph_network, or tna
object.}

\item{nodes}{Character vector of node names or integer vector of node
indices selecting which egos to report. NULL (default) uses every node.}

\item{order}{Integer neighbourhood order defining the ego network. 1
(default) is the standard ego network (ego + direct neighbours). Burt's
\code{effective_size} and \code{constraint} are only defined for
\code{order = 1} and are returned as \code{NA} otherwise.}

\item{mode}{For directed networks, which ties define the neighbourhood:
\code{"all"} (default), \code{"out"}, or \code{"in"}.}

\item{directed}{Logical or NULL. If NULL (default), auto-detect from matrix
symmetry.}

\item{...}{Additional arguments passed to \code{\link{to_igraph}}.}
}
\value{
A tidy data.frame of class \code{"cograph_ego_networks"} with one row
per ego and columns:
\describe{
\item{node}{Ego node name.}
\item{size}{Number of alters (ego-network size, excluding ego).}
\item{ego_ties}{Number of edges in the ego network (ego + alters).}
\item{ego_density}{Edge density of the ego network including ego.}
\item{alter_ties}{Number of edges among the alters only (excluding ego).}
\item{alter_density}{Edge density among the alters. Low values indicate
many structural holes / brokerage opportunities.}
\item{effective_size}{Burt's effective size of the ego network
(\code{order = 1} only).}
\item{constraint}{Burt's constraint (\code{order = 1} only).}
}
}
\description{
Extracts the ego network of each requested node (the node, its neighbours up
to a given order, and the ties among them) and reports a tidy table of
personal-network metrics: size, internal tie counts and densities, and Burt's
structural-hole measures. One row per ego.
}
\details{
\code{effective_size} and \code{constraint} are computed on the full network
(Burt's measures are defined directly from each node's order-1 ego network),
reusing the same implementations as \code{\link{centrality}} so results match
\code{centrality(x, measures = c("effective_size", "constraint"))}.
}
\examples{
adj <- matrix(c(
  0, 1, 1, 0, 0,
  1, 0, 1, 0, 0,
  1, 1, 0, 1, 1,
  0, 0, 1, 0, 1,
  0, 0, 1, 1, 0
), 5, 5, byrow = TRUE)
rownames(adj) <- colnames(adj) <- LETTERS[1:5]
cograph::ego_networks(adj)
}
\references{
Burt, R.S. (1992). \emph{Structural Holes: The Social Structure of
Competition}. Harvard University Press.
}
\seealso{
\code{\link{centrality}} (for \code{effective_size}, \code{constraint},
\code{dispersion}), \code{\link{select_neighbors}}, \code{\link{neighborhood_overlap}}
}
