Bipartite Graphs: Two Teams, One Graph

Posted on July 7, 2026 by "GraphArena Team"

Introduction

Imagine organizing a dance where the rule is simple: every dance must be between a person from Group A and a person from Group B — no dancing within the same group. That rule, translated into graph theory, is exactly what defines a bipartite graph.

Bipartite graphs are one of the most widely used structures in mathematics and computer science. They model everything from job assignments and web search rankings to biological protein interactions and exam scheduling. Understanding them deeply opens the door to a whole family of powerful algorithms.

In this post we will build intuition from scratch, prove key properties, and see why some graphs simply cannot be bipartite — no matter how hard you try.


Definition

Definition: A graph is bipartite if its vertex set can be partitioned into two disjoint, non-empty sets and — called the bipartition — such that every edge connects a vertex in to a vertex in .

Formally:

Let’s unpack what this means:

  • The word Bi means two — and partite means parts. So bipartite literally means two parts.
  • Every edge must cross the partition — edges within or within are forbidden.
  • and are sometimes called the left set and right set, or colour classes.

The pair is called a bipartition of .

The Golden Rule

You can draw edges between the two sets, but you can never draw an edge between two vertices in the same set.


A First Example

Here is a small bipartite graph with (orange) and (teal):

Notice:
- Every edge goes from an orange vertex to a teal vertex.
- No orange vertex connects to another orange vertex.
- No teal vertex connects to another teal vertex.
- Not every possible cross-edge needs to exist — this is not a complete bipartite graph. A bipartite graph only requires that existing edges all cross the partition.


The 2-Coloring Test

How to Detect a Bipartite Graph

The most practical way to check whether a graph is bipartite is the 2-coloring algorithm — also called BFS 2-coloring. The idea:

  1. Pick any unvisited vertex. Color it orange.
  2. Color all of its neighbours teal.
  3. Color all of their unvisited neighbours orange.
  4. Keep alternating. If you ever try to assign a color to a vertex that already has the opposite color you need, the graph is not bipartite.
  5. If you finish coloring every vertex without conflict, the graph is bipartite.

Walkthrough on the Example Above

Step through the coloring:
- Start at vertex 1 → color orange
- Neighbours of 1: 2, 3 → color teal
- Neighbours of 2 and 3: 4 → color orange
- Neighbours of 4: 5, 6 → color teal
- All vertices colored, no conflict. ✓ Bipartite!

The two color classes are (orange) and (teal).

The Key Insight

The 2-coloring algorithm works because bipartiteness is equivalent to being 2-colorable: you can assign one of two colors to every vertex so that no two adjacent vertices share the same color. This is also the definition of having chromatic number .


When It Fails: Odd Cycles

Why Triangles Are Not Bipartite

Consider three friends: You, Alex, and Sam — all friends with each other. That’s a triangle (, also called ).

Try to 2-color it:
- Vertex 1orange
- Vertex 2 is adjacent to 1 → teal
- Vertex 3 is adjacent to 2 → must be orange
- But vertex 3 is also adjacent to vertex 1, which is orangeconflict!

The red edge and red vertex mark the contradiction. The coloring algorithm fails, so this graph is not bipartite.

The Cycle Theorem

The failure above is not a coincidence. There is a precise theorem:

Theorem: A graph is bipartite if and only if it contains no odd-length cycles.

This means:
- Any graph with a triangle (), pentagon (), heptagon (), or any other odd cycle is never bipartite.
- Graphs with only even cycles (, , , …) are bipartite.

Odd cycle — (not bipartite)

The 5-cycle : following the alternating colors around the pentagon, vertex 5 needs to be orange (because it follows teal vertex 4), but vertex 5 is adjacent to vertex 1 which is also orange. Conflict — marked in red.

Even cycle — (bipartite)

The 6-cycle colors perfectly: odd-positioned vertices are orange, even-positioned are teal. Every edge crosses the partition. No conflict. is bipartite with and .

General rule: is bipartite is even.


Real-World Examples

Bipartite graphs are everywhere once you know what to look for.

Example 1: Dogs and Owners

  • Set A (orange): Dogs — Rex, Spot, Bella
  • Set B (teal): Owners — John, Mary, Sam
  • Edges: a line between a dog and a person means the person owns that dog

Rex is owned by both John and Mary. Spot belongs to Mary. Bella belongs to Sam. No dog owns a dog, and no human owns a human in this model — all edges are cross-set. ✓ Bipartite.

Example 2: The School Dance

Imagine a dance where only cross-gender pairs dance together:

  • Set A: Boys (Alice, Bob, Carlos)
  • Set B: Girls (Dana, Eve, Fiona)
  • Edges: a line between two people means they danced together

Because no same-side pair dances, the “who danced with whom” graph is always bipartite.

Example 3: Job Applicants and Positions

A classic application — the matching problem:

  • Set A: Applicants (people applying for jobs)
  • Set B: Job positions available
  • Edges: an applicant is connected to a job if they qualify for it

Finding a maximum matching in this bipartite graph (pairing as many applicants to unique jobs as possible) is solved by the Hungarian algorithm or Hopcroft-Karp algorithm — both run efficiently precisely because the graph is bipartite.

Example 4: A Group of Friends (Usually NOT Bipartite)

Take three friends: You, Alex, and Sam. You are friends with Alex, Alex is friends with Sam, and Sam is friends with you. That triangle we saw above — not bipartite, because it is an odd cycle.

But if you have four friends in a square: You → Alex → Sam → Jordan → You (a ), the coloring works perfectly: You, Sam and Alex, Jordan. Bipartite.


Isolated Vertices

What about a vertex with no edges at all? Such a vertex is called an isolated vertex.

Since it has no edges, it cannot violate the golden rule. When testing for bipartiteness, you can place it in either partition. Isolated vertices never prevent a graph from being bipartite.


The Degree Sum Theorem

There is a beautiful mathematical theorem unique to bipartite graphs.

The Theorem

In words: In any bipartite graph, the sum of degrees of vertices in Set A equals the sum of degrees of vertices in Set B, and both equal the total number of edges.

Why Is This True?

Every edge has exactly one endpoint in and one endpoint in . So:
- Each edge contributes exactly 1 to the degree sum in .
- Each edge contributes exactly 1 to the degree sum in .

Therefore both sums equal .

Note: this is different from the Handshaking Lemma (which says the total degree sum equals ). In a bipartite graph the total degree sum is split equally between the two sides.

Worked Example

  • Set A = (orange):
  • (connected to and )
  • (connected to , , and )
  • Set B = (teal):

  • (connected to and )
  • (connected to and )
  • (connected to only)
  • Total edges


Complete Bipartite Graphs

Definition

A complete bipartite graph is a bipartite graph in which every vertex in is connected to every vertex in . No cross-edge is missing.

If the regular bipartite graph is “some edges cross the partition”, then is the extreme case: “all possible edges cross the partition.”

Notation

where:
- — the number of vertices in Set A
- — the number of vertices in Set B

Properties of

Property Formula Explanation
Order (vertices) Just add both sets
Size (edges) Every vertex in connects to all in
Degree of vertices Each connects to all vertices in
Degree of vertices Each connects to all vertices in
Degree sequence repeated times, then repeated times
Is regular? Yes, iff Only when both partitions are the same size

: A First Complete Bipartite Graph

  • (orange), (teal)
  • Every orange vertex connects to every teal vertex
  • Order: vertices
  • Size: edges
  • Degrees: each orange vertex has degree ; each teal vertex has degree
  • Degree sequence:

: The Famous Utility Graph

(three orange, three teal) is perhaps the most famous bipartite graph in all of mathematics. It represents the classic “utilities problem”: can three houses each be connected to three utilities (water, gas, electricity) without any pipes crossing?

Properties of :
- Order: vertices
- Size: edges
- Degree of every vertex: (it is a 3-regular graph)
- Degree sequence:

The surprising fact: is not planar — it cannot be drawn in the plane without edge crossings. Together with , it is one of the two Kuratowski forbidden minors that characterize planar graphs:

Kuratowski’s Theorem: A graph is planar if and only if it contains no subdivision of or .

vs — Do Not Confuse Them!

Name Complete bipartite graph Complete graph
Structure Two sets; only cross-edges One set; all pairs connected
Is bipartite? ✓ Always ✗ Never (for )
Edges
Example : 9 edges : 15 edges

obeys the bipartite rule. (for ) violates it — every vertex connects to every other, including same-“side” vertices.


Summary of Key Facts

Property Bipartite Graph Complete Bipartite
Partition , Same, but all cross-edges present
Edge rule All edges cross partition All cross-edges exist (none missing)
Contains odd cycle? Never Never
2-colorable? Yes Yes
Order
Max edges (already at max)
Degree sum theorem Same; each -vertex has degree , each -vertex degree

Practice Problems

Problem 1: Is It Bipartite?

Question: Can the friendship graph “You — Alex — Sam — You” (a triangle) be bipartite?

Click to reveal solution

No. A triangle is the 3-cycle C₃, which is an odd cycle. By the Cycle Theorem, any graph containing an odd cycle is not bipartite. Try 2-coloring: You=orange, Alex=teal, Sam must be orange (follows teal), but Sam is also adjacent to You (orange). Conflict.

Problem 2: Degree Theorem

Question: A bipartite graph has vertices and vertices. Set A degrees are . What is the sum of degrees in Set B? How many edges are there?

Click to reveal solution

By the Degree Sum Theorem: $\sum_A \deg = 2 + 3 + 1 + 2 = 8 = |E|$.

Therefore $\sum_B \deg = 8$ as well. There are $|E| = 8$ edges total.

Problem 3: Complete Bipartite Properties

Question: For , find: (a) order, (b) size, (c) degree of each vertex in Set A, (d) degree of each vertex in Set B, (e) degree sequence.

Click to reveal solution

(a) Order: $4 + 5 = 9$ vertices

(b) Size: $4 \times 5 = 20$ edges

(c) Degree of Set A vertices: each connects to all 5 in B → degree $= 5$

(d) Degree of Set B vertices: each connects to all 4 in A → degree $= 4$

(e) Degree sequence: $[5, 5, 5, 5, 4, 4, 4, 4, 4]$

Problem 4: Is Bipartite?

Question: Is the 8-cycle bipartite? If yes, give the bipartition.

Click to reveal solution

Yes — $C_8$ is an even cycle, so it is bipartite.

Label the vertices $1, 2, 3, 4, 5, 6, 7, 8$ around the cycle.

$A = \{1, 3, 5, 7\}$ (orange), $B = \{2, 4, 6, 8\}$ (teal).

Every edge connects an odd-numbered vertex to an even-numbered vertex. ✓

Problem 5: Find n Given Edge Count

Question: A complete bipartite graph has 25 edges. Find .

Click to reveal solution

$|E| = n \times n = n^2 = 25$, so $n = 5$.

The graph is $K_{5,5}$ with $5 + 5 = 10$ vertices and 25 edges.

Problem 6: Trees Are Bipartite

Question: Every tree is bipartite. Can you explain why?

Click to reveal solution

A tree has no cycles at all. Since it contains no odd cycles (it contains no cycles of any length), the Cycle Theorem guarantees it is bipartite.

The bipartition can be found by rooting the tree: Set A = vertices at even depth (0, 2, 4, …), Set B = vertices at odd depth (1, 3, 5, …). Every tree edge connects a depth-$d$ vertex to a depth-$(d+1)$ vertex, which always crosses the partition. ✓

Problem 7: Regular Complete Bipartite

Question: For which values of and is a regular graph?

Click to reveal solution

In $K_{p,q}$, Set A vertices have degree $q$ and Set B vertices have degree $p$.

For the graph to be regular, all vertices must have the same degree: $p = q$.

$K_{p,q}$ is $p$-regular (equivalently $q$-regular) if and only if $p = q$.

Example: $K_{3,3}$ is 3-regular. $K_{2,3}$ is not regular (degrees are 2 and 3).


Applications

1. Matching and Assignment Problems

The most powerful use of bipartite graphs is maximum matching — pairing vertices from to vertices in such that as many pairs as possible are matched, with no vertex used twice.

Examples:
- Matching job applicants to positions
- Scheduling tasks to machines
- Assigning students to project groups
- Hospital resident matching

König’s Theorem (1931) states that in a bipartite graph, the size of the maximum matching equals the size of the minimum vertex cover — a deep result with no analogue in general graphs.

2. Web Search and Recommendation Systems

Google’s original PageRank algorithm modeled web links as a bipartite graph: one set = pages that link out, the other = pages being linked to. Modern recommendation engines (Netflix, Spotify) model users and items as two bipartite sets with edges representing ratings or views.

3. Exam and Resource Scheduling

A bipartite graph can model which exams share students: = exams, = students, edges = “student takes this exam.” A proper 2-coloring of a derived conflict graph then schedules exams into two non-overlapping time slots — a direct application of bipartite structure.

4. Network Flow

Many network-flow problems reduce to bipartite matching. Hall’s Marriage Theorem gives a necessary and sufficient condition for a perfect matching (every vertex in matched) to exist in a bipartite graph:

Hall’s Theorem: A bipartite graph has a perfect matching (matching all of ) if and only if for every subset , the neighbourhood .

5. Bioinformatics

Protein-protein interaction networks are often modeled as bipartite graphs: one set = proteins acting as “activators,” the other = proteins acting as “targets.” Drug discovery algorithms search for specific bipartite substructures.


Key Takeaways

  1. Definition: A bipartite graph partitions its vertices into two sets and ; every edge crosses between them.
  2. 2-Coloring: A graph is bipartite iff it can be 2-colored — equivalent to .
  3. Cycle Theorem: Bipartite iff no odd-length cycles ().
  4. Even cycles are bipartite; odd cycles are not. Trees are always bipartite.
  5. Degree Sum Theorem: .
  6. Complete bipartite : every -vertex connects to every -vertex. Order , size .
  7. is the famous non-planar bipartite graph (Kuratowski’s theorem).
  8. Applications: job matching, recommendation systems, scheduling, network flow, bioinformatics.

Explore Further

Use the GraphArena Playground to experiment:
- Build a bipartite graph and verify the degree sum theorem by hand
- Try to 2-color a and see exactly where it fails
- Construct and confirm it has 9 edges and is 3-regular
- Try adding a single edge within one partition and observe the graph is no longer bipartite
- Compare (9 edges, bipartite) with (15 edges, complete) — both have 6 vertices, very different structures

Bipartite graphs are the backbone of matching theory, network flow, and two-sided market models. Mastering them is an essential step in every graph theorist’s toolkit.