% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/bipartite.R
\name{project_bipartite}
\alias{project_bipartite}
\title{Project Bipartite Network to One-Mode}
\usage{
project_bipartite(x, mode = "rows", method = "sum", ...)
}
\arguments{
\item{x}{An incidence matrix (rows = type 1 nodes, columns = type 2 nodes)
where non-zero entries indicate connections. Can also be a data.frame with
columns \code{type1}, \code{type2}, and optionally \code{weight}.}

\item{mode}{Character. \code{"rows"} (default) projects onto row nodes
(result: n_rows x n_rows). \code{"columns"} projects onto column nodes
(result: n_cols x n_cols).}

\item{method}{Character. Projection method:
\describe{
\item{\code{"sum"}}{Weighted projection: \code{A \%*\% t(A)} (rows) or
\code{t(A) \%*\% A} (columns). Edge weight equals sum of shared
connection-weight products.}
\item{\code{"binary"}}{Co-occurrence count: binarize A first, then
compute overlap. Edge weight equals number of shared connections.}
\item{\code{"jaccard"}}{Jaccard similarity: shared / (total_i + total_j
- shared) for each pair.}
\item{\code{"cosine"}}{Cosine similarity: dot product of row (or column)
vectors divided by the product of their norms.}
\item{\code{"newman"}}{Newman's weighted projection (Newman 2001): each
shared affiliation contributes \code{1 / (d_k - 1)} where \code{d_k}
is the degree of the shared node. Gives more weight to connections
through exclusive affiliations.}
}}

\item{...}{Additional arguments (currently unused).}
}
\value{
A square adjacency matrix with row and column names preserved from
the input. Diagonal is set to 0 (no self-loops).
}
\description{
Projects a two-mode (bipartite/incidence) network into a one-mode adjacency
matrix. Row-mode projection yields a matrix of shared-column connections
among row nodes; column-mode projection does the converse.
}
\details{
For the Newman projection, affiliations shared with only one node of the
focal type (\code{d_k = 1}) are skipped, since \code{1 / (d_k - 1)} is
undefined. This follows the convention in Newman (2001).
}
\examples{
# Incidence matrix: 4 students x 3 courses
inc <- matrix(c(1, 1, 0,
                1, 0, 1,
                0, 1, 1,
                1, 1, 1), 4, 3, byrow = TRUE)
rownames(inc) <- paste0("S", 1:4)
colnames(inc) <- paste0("C", 1:3)

# Student co-enrollment (weighted)
cograph::project_bipartite(inc, mode = "rows", method = "sum")

# Course overlap (Jaccard similarity)
cograph::project_bipartite(inc, mode = "columns", method = "jaccard")

# Newman's weighted projection
cograph::project_bipartite(inc, mode = "rows", method = "newman")
}
\references{
Newman, M. E. J. (2001). Scientific collaboration networks. II. Shortest
paths, weighted networks, and centrality. \emph{Physical Review E}, 64(1),
016132.
}
\seealso{
\code{\link{is_bipartite}}, \code{\link{plot_heatmap}}
}
