% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/bipartite.R
\name{is_bipartite}
\alias{is_bipartite}
\title{Check if a Matrix Could Be Bipartite}
\usage{
is_bipartite(x)
}
\arguments{
\item{x}{A numeric matrix.}
}
\value{
Logical. \code{TRUE} if the matrix could represent a bipartite
network, \code{FALSE} otherwise.
}
\description{
Tests whether a matrix could represent a bipartite incidence matrix.
A non-square matrix is considered bipartite by default. For square matrices,
checks whether the corresponding graph has bipartite structure (i.e., nodes
can be partitioned into two groups with edges only between groups).
}
\details{
For non-square matrices, returns \code{TRUE} since they naturally represent
two-mode data (rows and columns are distinct node types).

For square matrices, the function checks whether the corresponding
undirected graph is bipartite by attempting a two-coloring via
\code{igraph::bipartite_mapping()} when igraph is available. Without igraph,
it uses a BFS-based two-coloring algorithm.
}
\examples{
# Non-square matrix is bipartite
inc <- matrix(c(1, 0, 1, 1, 1, 0), 2, 3)
cograph::is_bipartite(inc)

# Square bipartite-compatible adjacency
adj <- matrix(c(0, 0, 1, 1,
                0, 0, 1, 0,
                1, 1, 0, 0,
                1, 0, 0, 0), 4, 4, byrow = TRUE)
cograph::is_bipartite(adj)

# Non-bipartite (triangle)
tri <- matrix(c(0, 1, 1, 1, 0, 1, 1, 1, 0), 3, 3)
cograph::is_bipartite(tri)
}
