% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/core-periphery.R
\name{core_periphery}
\alias{core_periphery}
\title{Detect Core-Periphery Structure}
\usage{
core_periphery(
  x,
  method = c("continuous", "discrete"),
  directed = NULL,
  iter = 100,
  digits = NULL,
  ...
)
}
\arguments{
\item{x}{Network input: matrix, igraph, network, cograph_network, or tna object}

\item{method}{Character string; either "continuous" (default, Borgatti-Everett
model) or "discrete" (binary core/periphery assignment).}

\item{directed}{Logical or NULL. If NULL (default), auto-detect from matrix
symmetry. Set TRUE to force directed, FALSE to force undirected.}

\item{iter}{Integer; maximum number of iterations for the continuous algorithm.
Default 100.}

\item{digits}{Integer or NULL. Round numeric outputs to this many decimal
places. Default NULL (no rounding).}

\item{...}{Additional arguments passed to \code{\link{to_igraph}}}
}
\value{
A data frame with class \code{"cograph_core_periphery"} and columns
\code{node}, \code{role}, and \code{coreness}. Fitness, core density,
periphery density, and the original network are stored as attributes.
}
\description{
Identifies core-periphery structure in a network using either continuous
(Borgatti-Everett) or discrete methods. Core nodes are densely interconnected,
while periphery nodes connect primarily to the core.
}
\details{
\strong{Continuous method (Borgatti-Everett):}
Finds a coreness vector \code{c} (values 0-1) that maximizes the correlation
between the adjacency matrix and the ideal rank-1 pattern matrix
(the outer product of the coreness vector with itself). The algorithm
initializes from eigenvector centrality and iteratively refines via
power iteration until convergence.

\strong{Discrete method:}
Produces a binary core (1) / periphery (0) assignment. Starts from the
continuous solution, thresholds at the median, then greedily swaps node
assignments to maximize fitness. Discrete fitness is defined by high density
within the core and low density within the periphery.
}
\examples{
# Core-periphery in a simple network
adj <- matrix(c(
  0, 1, 1, 1, 0,
  1, 0, 1, 1, 0,
  1, 1, 0, 1, 1,
  1, 1, 1, 0, 1,
  0, 0, 1, 1, 0
), 5, 5)
rownames(adj) <- colnames(adj) <- LETTERS[1:5]
cp <- cograph::core_periphery(adj)
cp

# Discrete assignment
cp_disc <- cograph::core_periphery(adj, method = "discrete")
cp_disc$assignment

}
\references{
Borgatti, S.P. & Everett, M.G. (2000). Models of core/periphery structures.
\emph{Social Networks}, 21(4), 375-395.
\doi{10.1016/S0378-8733(99)00019-2}
}
\seealso{
\code{\link{centrality}}, \code{\link{network_summary}}
}
