Skip to content

IsBipartiteGraph ​

Whether a Graph's vertices split into two sets with every edge crossing between them.

✓ checked against that system · ! checked, with disagreements (hover a chip)Wolfram LanguageBipartiteGraphQ✓
IsBipartiteGraph(g)true iff a 2-colouring exists (BFS, underlying graph, direction ignored) — false for any graph with an odd cycle, including a self-loop.
Typed signatures
TypePackageApplies
(value) -> booleancombinatoricsalways

Domain: Collections

Details
  • Wolfram calls this BipartiteGraphQ; this library uses the Is… spelling everywhere.

Examples

2 more kept as data, checked against the oracles
Basic #
live ↗
InIsBipartiteGraph(CycleGraph(6))\mathrm{IsBipartiteGraph}(\mathrm{CycleGraph}(6))OutTrue\mathrm{True}
live ↗
InIsBipartiteGraph(CycleGraph(5))\mathrm{IsBipartiteGraph}(\mathrm{CycleGraph}(5))OutFalse\mathrm{False}
live ↗
InIsBipartiteGraph(Graph([UndirectedEdge(1,1)]))\mathrm{IsBipartiteGraph}(\mathrm{Graph}(\bigl\lbrack\mathrm{UndirectedEdge}(1, 1)\bigr\rbrack))OutFalse\mathrm{False}
Properties #

A triangle is an odd cycle, so it cannot be two-coloured

live ↗
InIsBipartiteGraph(CycleGraph(3))\mathrm{IsBipartiteGraph}(\mathrm{CycleGraph}(3))OutFalse\mathrm{False}
About
Examples6
Checked againstWolfram Language 5 agree
CrosswalkWolfram Language

See also: IsConnectedGraph, CycleGraph