% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/bipartite_groups.R
\name{bipartite_groups}
\alias{bipartite_groups}
\title{Hypergraph from bipartite group / event data}
\usage{
bipartite_groups(data, player, group, weight = NULL)
}
\arguments{
\item{data}{Data frame in long format. Must contain \code{player} and \code{group}
columns; optionally a \code{weight} column.}

\item{player}{Character. Name of the column whose values become the
hypergraph's nodes (players, participants, actors).}

\item{group}{Character. Name of the column whose values become the
hypergraph's hyperedges (groups, sessions, teams).}

\item{weight}{Character or \code{NULL}. If supplied, the column is summed per
\verb{(player, group)} pair to produce a weighted incidence matrix. Default
\code{NULL} produces a 0/1 binary incidence matrix.}
}
\value{
A \code{net_hypergraph} object with the same structure produced by
\code{\link[=build_hypergraph]{build_hypergraph()}} (\code{hyperedges}, \code{incidence}, \code{nodes}, \code{n_nodes},
\code{n_hyperedges}, \code{size_distribution}, \code{params}). The \code{params} list
records \code{source = "bipartite_groups"} and the original column names.
}
\description{
Constructs a \link[=build_hypergraph]{net_hypergraph} from long-format event
data in which each row records a \code{player} participating in a \code{group}
(a session, team, project, transaction, or any group context). Each
unique group becomes one hyperedge spanning the players that appeared in
it. Optional \code{weight} column produces a weighted incidence matrix.
}
\details{
The bipartite representation preserves the full group structure without
projecting to a pairwise network. A group of three players A, B, C
produces a single 3-hyperedge containing all three, not three pairwise
edges AB, AC, BC. This avoids information loss when group interactions are
the primary unit of analysis (Perc et al. 2013).

Unlike \code{\link[=build_hypergraph]{build_hypergraph()}} (which derives hyperedges from a network's
clique structure), \code{bipartite_groups()} takes group memberships
directly. The two functions are complementary:
\itemize{
\item \code{bipartite_groups()} - when group membership is observed
(sessions, transactions, co-authorships).
\item \code{build_hypergraph()} - when only pairwise interactions are
observed and triadic structure must be inferred from triangles.
}

Rows with \code{NA} in either the \code{player} or \code{group} column (or, when
supplied, the \code{weight} column) are dropped silently.
}
\note{
(experimental) Validated against a hand-computed \code{table()} incidence
reference only; no independent R package exposes the
long-format-to-binary-incidence primitive, because the operation is
definitionally \code{table()}. The code path is a direct one-to-one
restatement of its definition.
}
\examples{
df <- data.frame(
  player = c("Alice", "Bob", "Carol", "Alice", "Bob",
             "Dave", "Carol", "Dave", "Eve"),
  session = c("S1", "S1", "S1", "S2", "S2",
              "S3", "S3", "S3", "S3")
)
hg <- bipartite_groups(df, player = "player", group = "session")
print(hg)
summary(hg)

}
\references{
Perc, M., Gomez-Gardenes, J., Szolnoki, A., Floria, L. M., & Moreno, Y.
(2013). Evolutionary dynamics of group interactions on structured
populations: a review. \emph{Journal of the Royal Society Interface}
10(80), 20120997. \doi{10.1098/rsif.2012.0997}
}
\seealso{
\code{\link[=build_hypergraph]{build_hypergraph()}} for the clique-based constructor.
}
