GraphTheory
IsBipartite
test if graph is bipartite
Calling Sequence
Parameters
Description
Examples
IsBipartite(G)
IsBipartite(G, P)
G
-
graph
P
(optional) name
IsBipartite returns true if the graph G is bipartite and false otherwise. If a variable name P is specified, then this name is assigned a bipartition of the vertices as a list of lists.
A graph G is bipartite if its set of vertices can be partitioned into two sets, V1 and V2, such that every edge in G connects a vertex in V1 or V2 to a vertex in the other set.
with⁡GraphTheory:
K32≔CompleteGraph⁡3,2
K32≔Graph 1: an undirected graph with 5 vertices and 6 edge(s)
IsBipartite⁡K32,bp
true
bp
1,2,3,4,5
DrawGraph⁡K32,style=bipartite
AdjacencyMatrix⁡K32
0001100011000111110011100
G≔CycleGraph⁡5
G≔Graph 2: an undirected graph with 5 vertices and 5 edge(s)
IsBipartite⁡G
false
See Also
AdjacencyMatrix
BipartiteMatching
DrawGraph
RandomGraphs[RandomBipartiteGraph]
Download Help Document