This function can return a sparse or dense bipartite adjacency matrix of a bipartite network. The bipartite adjacency matrix is an \(n\) times \(m\) matrix, \(n\) and \(m\) are the number of vertices of the two kinds.
Usage
as_biadjacency_matrix(
graph,
types = NULL,
...,
weights = NULL,
names = TRUE,
sparse = FALSE,
attr = deprecated()
)Arguments
- graph
The input graph. The direction of the edges is ignored in directed graphs.
- types
An optional vertex type vector to use instead of the
typevertex attribute. You must supply this argument if the graph has notypevertex attribute.- ...
These dots are for future extensions and must be empty.
- weights
One of the following:
NULL(default): use theweightedge attribute if the graph has one, otherwise return a traditional (unweighted) adjacency matrix.NA: explicitly unweighted, ignoring anyweightedge attribute.A numeric or logical vector of length
ecount(): use these values directly as edge weights.A character scalar: the name of an edge attribute whose values are used as weights. The attribute must be numeric or logical.
If multiple edges share endpoints, the value of an arbitrarily chosen edge is included in the matrix.
- names
Logical, if
TRUEand the vertices in the graph are named (i.e. the graph has a vertex attribute calledname), 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.- sparse
Logical, if it is
TRUEthen a sparse matrix is created, you will need theMatrixpackage for this.- attr
Use
weightsinstead. If supplied, the value is forwarded toweightsas a character edge attribute name.
Details
Bipartite graphs have a type vertex attribute in igraph, this is
boolean and FALSE for the vertices of the first kind and 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.
Related documentation in the C library
get_biadjacency(), get_edgelist(), vcount(), edges(), get_eids(), ecount()
See also
graph_from_biadjacency_matrix() for the opposite operation.
Other conversion:
as.matrix.igraph(),
as_adj_list(),
as_adjacency_matrix(),
as_data_frame(),
as_directed(),
as_edgelist(),
as_graphnel(),
as_long_data_frame(),
graph_from_adj_list(),
graph_from_graphnel()
Author
Gabor Csardi csardi.gabor@gmail.com
Examples
g <- make_bipartite_graph(c(0, 1, 0, 1, 0, 0), c(1, 2, 2, 3, 3, 4))
as_biadjacency_matrix(g)
#> 2 4
#> 1 1 0
#> 3 1 1
#> 5 0 0
#> 6 0 0
