1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
|
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/conversion.R
\name{as_biadjacency_matrix}
\alias{as_biadjacency_matrix}
\title{Bipartite adjacency matrix of a bipartite graph}
\usage{
as_biadjacency_matrix(
graph,
types = NULL,
attr = NULL,
names = TRUE,
sparse = FALSE
)
}
\arguments{
\item{graph}{The input graph. The direction of the edges is ignored in
directed graphs.}
\item{types}{An optional vertex type vector to use instead of the
\code{type} vertex attribute. You must supply this argument if the graph has
no \code{type} vertex attribute.}
\item{attr}{Either \code{NULL} or a character string giving an edge
attribute name. If \code{NULL}, then a traditional bipartite adjacency matrix is
returned. If not \code{NULL} then the values of the given edge attribute are
included in the bipartite adjacency matrix. If the graph has multiple edges, the edge
attribute of an arbitrarily chosen edge (for the multiple edges) is
included.}
\item{names}{Logical scalar, if \code{TRUE} and the vertices in the graph
are named (i.e. the graph has a vertex attribute called \code{name}), then
vertex names will be added to the result as row and column names. Otherwise
the ids of the vertices are used as row and column names.}
\item{sparse}{Logical scalar, if it is \code{TRUE} then a sparse matrix is
created, you will need the \code{Matrix} package for this.}
}
\value{
A sparse or dense matrix.
}
\description{
This function can return a sparse or dense bipartite adjacency matrix of a bipartite
network. The bipartite adjacency matrix is an \eqn{n} times \eqn{m} matrix, \eqn{n}
and \eqn{m} are the number of vertices of the two kinds.
}
\details{
Bipartite graphs have a \code{type} vertex attribute in igraph, this is
boolean and \code{FALSE} for the vertices of the first kind and \code{TRUE}
for vertices of the second kind.
Some authors refer to the bipartite adjacency matrix as the
"bipartite incidence matrix". igraph 1.6.0 and later does not use
this naming to avoid confusion with the edge-vertex incidence matrix.
}
\examples{
g <- make_bipartite_graph(c(0, 1, 0, 1, 0, 0), c(1, 2, 2, 3, 3, 4))
as_biadjacency_matrix(g)
}
\seealso{
\code{\link[=graph_from_biadjacency_matrix]{graph_from_biadjacency_matrix()}} for the opposite operation.
Other conversion:
\code{\link{as.matrix.igraph}()},
\code{\link{as_adj_list}()},
\code{\link{as_adjacency_matrix}()},
\code{\link{as_data_frame}()},
\code{\link{as_directed}()},
\code{\link{as_edgelist}()},
\code{\link{as_graphnel}()},
\code{\link{as_long_data_frame}()},
\code{\link{graph_from_adj_list}()},
\code{\link{graph_from_graphnel}()}
}
\author{
Gabor Csardi \email{csardi.gabor@gmail.com}
}
\concept{conversion}
\keyword{graphs}
|