# bipartite.mapping

0th

Percentile

##### Decide whether a graph is bipartite

This function decides whether the vertices of a network can be mapped to two vertex types in a way that no vertices of the same type are connected.

Keywords
graphs
##### Usage
bipartite.mapping(graph)
graph
The input graph.
##### Details

A bipartite graph in igraph has a type vertex attribute giving the two vertex types.

This function simply checks whether a graph could be bipartite. It tries to find a mapping that gives a possible division of the vertices into two classes, such that no two vertices of the same class are connected by an edge.

The existence of such a mapping is equivalent of having no circuits of odd length in the graph. A graph with loop edges cannot bipartite.

Note that the mapping is not necessarily unique, e.g. if the graph has at least two components, then the vertices in the separate components can be mapped independently.

##### Value

• A named list with two elements:
• resA logical scalar, TRUE if the can be bipartite, FALSE otherwise.
• typeA possibly vertex type mapping, a logical vector. If no such mapping exists, then an empty vector.

##### concept

• Bipartite graph
• Two-mode network

##### Aliases
• bipartite.mapping
##### Examples
## A ring has just one loop, so it is fine
g <- graph.ring(10)
bipartite.mapping(g)

## A star is fine, too
g2 <- graph.star(10)
bipartite.mapping(g2)

## A graph containing a triangle is not fine
g3 <- graph.ring(10)
bipartite.mapping(g3)