A bipartite graph is projected into two one-mode networks

## Usage

```
bipartite_projection(
graph,
types = NULL,
multiplicity = TRUE,
probe1 = NULL,
which = c("both", "true", "false"),
remove.type = TRUE
)
bipartite_projection_size(graph, types = NULL)
```

## Arguments

- graph
The input graph. It can be directed, but edge directions are ignored during the computation.

- types
An optional vertex type vector to use instead of the ‘

`type`

’ vertex attribute. You must supply this argument if the graph has no ‘`type`

’ vertex attribute.- multiplicity
If

`TRUE`

, then igraph keeps the multiplicity of the edges as an edge attribute called ‘weight’. E.g. if there is an A-C-B and also an A-D-B triple in the bipartite graph (but no more X, such that A-X-B is also in the graph), then the multiplicity of the A-B edge in the projection will be 2.- probe1
This argument can be used to specify the order of the projections in the resulting list. If given, then it is considered as a vertex id (or a symbolic vertex name); the projection containing this vertex will be the first one in the result list. This argument is ignored if only one projection is requested in argument

`which`

.- which
A character scalar to specify which projection(s) to calculate. The default is to calculate both.

- remove.type
Logical scalar, whether to remove the

`type`

vertex attribute from the projections. This makes sense because these graphs are not bipartite any more. However if you want to combine them with each other (or other bipartite graphs), then it is worth keeping this attribute. By default it will be removed.

## 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.

`bipartite_projection_size()`

calculates the number of vertices and edges
in the two projections of the bipartite graphs, without calculating the
projections themselves. This is useful to check how much memory the
projections would need if you have a large bipartite graph.

`bipartite_projection()`

calculates the actual projections. You can use
the `probe1`

argument to specify the order of the projections in the
result. By default vertex type `FALSE`

is the first and `TRUE`

is
the second.

`bipartite_projection()`

keeps vertex attributes.

## See also

Bipartite graphs
`bipartite_mapping()`

,
`is_bipartite()`

,
`make_bipartite_graph()`

## Author

Gabor Csardi csardi.gabor@gmail.com

## Examples

```
## Projection of a full bipartite graph is a full graph
g <- make_full_bipartite_graph(10, 5)
proj <- bipartite_projection(g)
graph.isomorphic(proj[[1]], make_full_graph(10))
#> [1] TRUE
graph.isomorphic(proj[[2]], make_full_graph(5))
#> [1] TRUE
## The projection keeps the vertex attributes
M <- matrix(0, nrow = 5, ncol = 3)
rownames(M) <- c("Alice", "Bob", "Cecil", "Dan", "Ethel")
colnames(M) <- c("Party", "Skiing", "Badminton")
M[] <- sample(0:1, length(M), replace = TRUE)
M
#> Party Skiing Badminton
#> Alice 1 1 0
#> Bob 0 1 0
#> Cecil 0 1 0
#> Dan 0 1 1
#> Ethel 0 0 0
g2 <- graph_from_biadjacency_matrix(M)
g2$name <- "Event network"
proj2 <- bipartite_projection(g2)
print(proj2[[1]], g = TRUE, e = TRUE)
#> IGRAPH eda2d12 UNW- 5 6 -- Event network
#> + attr: name (g/c), name (v/c), weight (e/n)
#> + edges from eda2d12 (vertex names):
#> [1] Alice--Bob Alice--Cecil Alice--Dan Bob --Cecil Bob --Dan
#> [6] Cecil--Dan
print(proj2[[2]], g = TRUE, e = TRUE)
#> IGRAPH 9c40952 UNW- 3 2 -- Event network
#> + attr: name (g/c), name (v/c), weight (e/n)
#> + edges from 9c40952 (vertex names):
#> [1] Party --Skiing Skiing--Badminton
```