Bipartite graphs [00MX]
- September 22, 2026
Bipartite graphs: intuition and motivation [00MZ]
- September 22, 2026
Suppose we are trying to schedule TA hours. We have a set of available time slots and a set of TAs, and each TA is available during certain time slots. We can model this situation with a graph: make a vertex for each TA, a vertex for each time slot, and connect each TA to all the time slots for which they are available.
Notice that in this example, we have two kinds of vertices, and the edges only go from one kind of vertex to the other kind. This kind of graph is called bipartite, and they show up a lot—any time we want to model some kind of relationship between two sets.
Not only can we use bipartite graphs to model lots of things, but many problems which are difficult for graphs in general become easy in the case of bipartite graphs. For example, the problem of scheduling TAs is a matching or assignment problem, which is difficult for graphs in general, but can be solved for bipartite graphs using a maximum flow (which we will learn about later in the semester).
Definition Bipartite graph [00MY]
- September 22, 2026
An undirected graph G = (V,E) is bipartite if V can be partitioned into two sets L and R such that every edge has one endpoint in L and one in R.
Definition Graph coloring [00N0]
- September 23, 2026
As a generalization of bipartite graphs, we can also think about graph coloring. The idea is to give every vertex a "color" in such a way that no edge has the same color on both ends.
Definition k-colorable [00N1]
- September 23, 2026
An undirected graph is k-colorable if it is possible to assign each vertex one of k colors, in such a way that no two vertices of the same color are adjacent.
Remark Bipartite = 2-colorable [00N2]
- September 23, 2026
Being bipartite is the same as being 2-colorable—instead of thinking in terms of putting the vertices on one side or the other, we can think in terms of coloring them, say, red and blue. But we can also talk about graphs being 3-colorable, 4-colorable, and so on. Deciding whether a graph is 2-colorable—that is, bipartite—can be done quite efficiently, as we will see in a moment. Surprisingly, it turns out that deciding whether a graph is k-colorable for k \geq 3 is quite difficult!
Theorem Bipartite = no odd cycles [00N3]
- September 23, 2026
An undirected graph G is bipartite iff it has no odd-length cycles.
Proof.
- September 23, 2026
Subproof. Bipartite = no odd cycles ›
- September 23, 2026
Subproof. Bipartite = no odd cycles ›
- September 23, 2026
(\Longleftarrow ) Suppose G = (V,E) has no odd-length cycles; we must show G is bipartite. Pick an arbitrary vertex s and run a BFS, generating layers L_0, L_1, L_2, …. Then define \begin {gather*} L = L_0 \cup L_2 \cup L_4 \cup \dots \\ R = L_1 \cup L_3 \cup L_5 \cup \dots \end {gather*}
We now claim that L and R are a vertex partition showing that G is bipartite, that is, every edge \{x,y\} \in E has one endpoint in L and one in R. By the single-layer-difference property of BFS, there can’t be any edges between different layers within L or R. The only possibility we have to worry about is an edge between two vertices in the same layer; we must show this can't happen.
So, suppose \{x,y\} \in E and x,y \in L_j; we will derive a contradiction. Let z be the least common ancestor of x and y in the BFS tree, and suppose z has height h above x and y. Then z \to x \to y \to z forms a cycle of length 2h + 1, which is odd—but we assumed G has no odd cycles. Therefore such an edge \{x,y\} within a single layer cannot exist, and G is indeed bipartite.
Remark BFS is a test for bipartiteness [00N4]
- September 23, 2026
The above proof does much more than just establish the truth of the theorem. It actually describes a practical algorithmic test for bipartiteness. Run a BFS starting from any vertex; then G is bipartite iff there is no edge between two vertices in the same layer. If there is a cross-edge within a layer, then we have found an odd cycle; otherwise, we have found a 2-coloring of the graph.
That is, this algorithm tells us not only whether a graph is bipartite, but gives us concrete (and easily checkable) evidence to support the conclusion: either an odd cycle, showing the graph is not bipartite, or a specific partition of the vertices showing that it is.