% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/clique_expansion.R
\name{clique_expansion}
\alias{clique_expansion}
\title{Clique expansion of a hypergraph}
\usage{
clique_expansion(hg, weighted = TRUE)
}
\arguments{
\item{hg}{A \code{net_hypergraph} object as returned by \code{\link[=build_hypergraph]{build_hypergraph()}}
or \code{\link[=bipartite_groups]{bipartite_groups()}}.}

\item{weighted}{Logical. If \code{TRUE} (default), use the hypergraph's
incidence values directly (so weighted hypergraphs from
\code{\link[=bipartite_groups]{bipartite_groups()}} produce weighted projections). If \code{FALSE},
binarise the incidence first so \code{W[i, j]} is just the count of
shared hyperedges.}
}
\value{
A \code{netobject} (also \code{cograph_network}) with \code{method = "clique_expansion"}, undirected, with weighted symmetric adjacency
\code{W = incidence \%*\% t(incidence)} and zero diagonal.
}
\description{
Projects a \link[=build_hypergraph]{net_hypergraph} to a standard pairwise
\link[=build_network]{netobject} (the \emph{clique expansion} - also called the
"downgrade" of a hypergraph to a dyadic graph). Each hyperedge of size
k contributes 1 (or its weight) to every pair of its members. The
resulting edge weight \code{W[i, j]} equals the number of hyperedges
containing both \code{i} and \code{j} (binary incidence) or the sum of incidence
products (weighted incidence).
}
\details{
The clique expansion is the standard "loss-y but lossless-on-pairwise"
projection: it preserves \emph{which pairs co-occurred} and \emph{how often} but
discards the higher-order grouping. Comparing \code{clique_expansion(hg)} to
a directly-estimated pairwise network (e.g. via \code{\link[=cooccurrence]{cooccurrence()}} on
the same data) quantifies how much information was carried by the
hyperedge structure.

Computed in one BLAS call via \code{tcrossprod(incidence)}; runs in
\code{O(n_nodes^2 * n_hyperedges)} time, fast for typical sizes.

Closes the I/O cycle: event data -> \code{\link[=bipartite_groups]{bipartite_groups()}} ->
\code{clique_expansion()} -> any function that accepts a \code{netobject}
(centrality, bootstrap, clustering, plotting via cograph).
}
\note{
(experimental) Validated against \code{tcrossprod(incidence)} with zero
diagonal. No external R package exposes clique expansion as a primitive;
the implementation is a direct one-line restatement of the definition.
}
\examples{
df <- data.frame(
  player  = c("A", "B", "C", "A", "B", "D", "C", "D", "E"),
  session = c("S1", "S1", "S1", "S2", "S2", "S3", "S3", "S3", "S3")
)
hg  <- bipartite_groups(df, player = "player", group = "session")
net <- clique_expansion(hg)
net$weights

}
\references{
Tian, Y., & Zafarani, R. (2024). Higher-order network analysis methods.
\emph{SIGKDD Explorations} 26(1), Section 5.1.5.
}
\seealso{
\code{\link[=build_hypergraph]{build_hypergraph()}}, \code{\link[=bipartite_groups]{bipartite_groups()}}, \code{\link[=build_network]{build_network()}}.
}
