# Union of matchings is not necessarily bipartite?

I'm working my way through MIT's 6.042, here's a question on bipartite graphs that's got me confused;

show union of matchings is bipartite

Here's my reasoning, based on the wording of the question we can't be sure that $$G'$$ is bipartite.

The definition for bi-partite is that nodes can be partitioned into two subsets of nodes, $$V_L$$ and $$V_R$$, where $$V = V_L \cup V_R$$, so that every edge has one node in $$V_L$$ and the other node in $$V_R$$ (or vice versa).

By definition, a matching produces a bipartite graph, because no two edges are incident to a common vertex. Suppose we remove all the edges from $$G'$$ that belong to $$M_2$$, to give us a bipartite graph $$G* = (V, M_1)$$.

Then, for each edge $$m \in M_2$$, we add it to $$G*$$, with the following cases,

Case 1: $$m \in M_1$$. Since the edge already exists, and edges are uniquely added to a set, m is ignored. The bipartite graph is unchanged, so it remains bipartite.

Case 2 $$m \ni M_1$$. This breaks down into two subcases.

Sub-Case 1: $$m = \langle v_a — v_b \rangle. v_a \in V_L, v_b \in V_R$$. That is, the edge is not in $$M_1$$, and connects a node in $$V_L$$ to a node in $$V_R$$. This fits the condition for being bipartite, and so the resulting graph is also bipartite.

Sub-Case 2: $$m = \langle v_a — v_b \rangle. v_a,v_b \in V_L \text{ or } v_a,v_b \in V_R$$. That is, the edge does not connect nodes in different partitions, it connects nodes in the same partition. But then, this means the graph is not bipartite, because not all edges connects nodes in opposite partitions.

So $$G'$$ is not always bipartite.

Clearly I've misunderstood something, but I can't see what. The top answer from the linked question gives a contradiction, but from what I understand that's only the case if we're talking about a perfect matching, which is not what the question asks. Since $$M_1$$ and $$M_2$$ are not perfect matchings, there's no guarantee that any given edge occurs in one, both or either of them.

I've added an example of this with a rendered graph on on my github pages where I'm writing everything up.

Any help with this question would be much appreciated!

• HiI Your misunderstanding is that in SubCase2, this might not lead to a contradiction because the resulting graph can be rearranged to show it is bipartite. Suppose for example that in M1 we had edges ab and cd where a and c are in V_L. Then when we add edge ac, the graph is still bipartite, but now with parts {a,d} and {b,c}
– dbal
Jul 14, 2021 at 13:11
• Really, the proof of this goes like this: When you take the union of two matchings, the maximum degree of the resulting graph is 2. This means the resulting graph is a union of paths and cycles. Paths are bipartite. So you just have to show that any resulting cycles are of even length.
– dbal
Jul 14, 2021 at 13:12

I worked on this some more, I think I have a reasonably good proof now. Here it is, in case you check my github pages and wonder where the example went;

Suppose we have two subsets of nodes, $$V_L$$ and $$V_R$$, where $$V = V_L \cup V_R$$. $$G'$$ is bipartite if every node can be added to either $$V_L$$ or $$V_R$$ without sharing an edge with an existing node in that set.

By definition, a matching produces a bipartite graph, because no two edges are incident to a common vertex. A graph produced from a matching also has a maximum degree of 1, for the same reason.

If $$G'$$ has a degree of 1, then it is trivially bipartite. So we must show that $$G'$$ is bipartite if it has a degree higher than 1.

Lemma 1: $$G'$$ has a maximum degree of 2.

Proof: By contradiction. Suppose we have a node, v, in $$G'$$ incident to edges $$e_t$$ where $$\ t > 2$$. By definition of a matching, the vertex (and the edge it is matched with) can appear once and only once per matching. We also know the edges in $$G'$$ are a union of exactly two matchings.

So, if t is greater than 2, $$e_1$$ and $$e_2$$ could come from $$M_1$$ and $$M_2$$ respectively, but $$e_3$$ could not come from either, which is a contradiction.

So we can conclude a graph produced from two matchings will have, at most, degree of 2. $$\square$$

Next, let's consider the connected component of any node in $$G'$$. Suppose we have a node, v, connected by the shortest number of edges to another node, u. We start by adding v to $$V_L$$, and for every node in the same component we recursively add every adjacent node to the opposite partition. This means the number of edges from v to any node in $$V_L$$ will be even, and the number of edges from v to any node in $$V_R$$ will be odd.

A path is bipartite, because each node is present only once, and there are no cycles. So each node can be grouped by the opposite of its neighbours.

Suppose two adjacent nodes, w and x are both connected to v, forming a cycle $$v—...w—x—...v$$.

If the parity of $$v—..w$$ and $$v—...x$$ is different, then by the above, w and x are in opposite partitions, so the cycle is bipartite.

.. note::

The sum of numbers of opposite parity is odd, plus 1 (for the edge $$w—x$$),
meaning this is a cycle of even length.


If the parity of $$v—..w$$ and $$v—...x$$ is the same, then w and x would be in the same partition. But since they share an edge they can't be added to the same partition, and so the graph cannot be bipartite.

.. note::

The sum of any two numbers of the same parity is always even.


Since v and w are adjacent, the parity of the number of edges in the the cycle $$v—...w—x—...v$$ is odd. So we must prove that $$G'$$ cannot have any cycles of odd length.

Lemma 2: $$G'$$ cannot have any cycles of odd length

Proof: By contradiction. Assume $$G'$$ has a cycle of length i, where i is an odd number. Suppose we walk around the cycle. Since the edges in $$G'$$ are a union of matchings, each step must travel along an edge, e, such that $$e_j$$ and $$e_{j+1}$$ are from the opposite matching, for some integer $$j \in \Bbb Z$$.

This is because matchings cannot contain edges connected to a node more than once. So if a node has more than one edge, they must come from different matchings.

.. note::

By lemma 1, we know there are at most 2 edges for every node in $$G'$$.
So edges are from either $$M_1$$ or $$M_2$$.


This means, for any $$k,m \in \Bbb Z$$, if $$\ k\ mod\ i\$$ and $$\ m\ mod\ i\$$ are both even, then they must come from the same matching. However, since i is odd, $$\ 0\ mod\ i\$$ and $$\ i-1\ mod\ i\$$ are both even, which would put two adjacent edges in the same matching. This is a contradiction, so we can assume there are no cycles of odd length in $$G'$$ $$\square$$

By lemma 2, we know $$G'$$ can only be comprised of paths and even cycles, which as we showed, both result in a bipartite graph. Therefore, $$G'$$ is bipartite. $$\blacksquare!$$