Proof a graph is bipartite if and only if it contains no odd cycles How can we prove that a graph is bipartite if and only if all of its cycles have even order? Also, does this theorem have a common name? I found it in a maths Olympiad toolbox.
 A: One direction is very easy: if $G$ is bipartite with vertex sets $V_1$ and $V_2$, every step along a walk takes you either from $V_1$ to $V_2$ or from $V_2$ to $V_1$. To end up where you started, therefore, you must take an even number of steps.
Conversely, suppose that every cycle of $G$ is even. Let $v_0$ be any vertex. For each vertex $v$ in the same component $C_0$ as $v_0$ let $d(v)$ be the length of the shortest path from $v_0$ to $v$. Color red every vertex in $C_0$ whose distance from $v_0$ is even, and color the other vertices of $C_0$ blue. Do the same for each component of $G$. Check that if $G$ had any edge between two red vertices or between two blue vertices, it would have an odd cycle. Thus, $G$ is bipartite, the red vertices and the blue vertices being the two parts.
A: The following is an expanded version of Brian's answer. Brian's answer is almost perfect, except that there may be a gap between "if G had any edge between two red vertices or between two blue vertices" and "it would have an odd cycle", which is not that obvious, at least to me(since we can only conclude that there exists a closed walk of odd numbers of edges). We first prove a lemma stating that if there is an odd closed walk in a graph, then there is an odd closed cycle.
Lemma 1 If there is an odd closed walk in a graph, then there is an odd closed cycle.
Proof$\;$ We induct on the number of edges $k$ of the odd closed walk. The base case $k=1$, when the closed walk is a loop, holds trivially. Assume that, for some positive integer $r > 1$, Lemma 1 is true for all odd numbers $k\le2r-1$. Let $W=(w_1, \dots, w_{2r+1}, w_1)$ be a closed walk of $2r+1$ edges. If all vertices in $W$ is different except for $w_1$, then we have a cycle of length $2r+1$. If there exists two identical vertices $w_i=w_j$ for $1<i<j\le 2r+1$, then $W$ can be written as $(w_1, \dots,w_i, \dots, w_j,\dots, w_1)$. Thus, we now have two closed walks $W_1=(w_i,w_{i+1} \dots, w_j)$ and $W_2=(w_j,w_{j+1} \dots, w_i)$. The summation of the length of $W_1$ and $W_2$ equals to the length of $W$. Since $W$ is of odd length, one of $W_1$ and $W_2$ must be of odd length $\le 2r-1$. By our assumption, there must be a an odd cycle in $W_1$ or $W_2$, and thus in $W$, which completes our induction. $\square$
Theorem 1 If there are no odd cycles in a graph, then the graph is bipartite.
Proof$\;$ Suppose there is no odd cycles in graph $G=(V,E)$. It is also assumed  that, without loss of generality, $G$ is connected. Then $V$ can be partitioned into $(A,B)$, where
$$A=\{v\in V|\text{the shortest path between $v$ and $v_0$ is of even length}\}$$
$$B=\{v\in V|\text{the shortest path between $v$ and $v_0$ is of odd length}\}$$
Next we prove that there is no edge between any two vertices in $A$ or $B$. Suppose for contradiction that there exists an edge $(x,y)\in E$ such that $x,y \in A$ or $x,y \in B$ . Then the shortest path from $x$ to $v_0$, the shortest path from $y$ to $v_0$, together with edge $(x,y)$, form a closed walk: $(v_0, \dots,x,y, \dots,v_0)$, which is of odd length. By lemma 1, $G$ contains an odd cycle, which is a contradiction.
Therefore, $G$ is a bipartite graph between $A$ and $B$.
$\square$
A: 
does this theorem have a common name?

It is sometimes called König's Theorem (1936), for example in lecture notes here. 

However, this name is ambiguous.
A: The fact that no bipartite graph has any odd cycles is proved in other answers.
Theorem: If a graph $G$ has no odd cycles, $G$ is bipartite.
Proof: Suppose not. Then there is a least $n$ where there is an $n$-node counterexample. Let $G$ be such a counterexample.
Let $v$ be any node of $G$. $G\setminus v$ has $n-1$ nodes, and no odd cycles, and so is bipartite. Two-colour its nodes red and blue. Restore $v$.
If all $v$'s neighbours have the same colour, give $v$ the opposite colour. Then $G$ is bipartite; contradiction.
Suppose $v$ has a red neighbour $u$ and a blue neighbour $w$ in the same component of $G\setminus v$. Then $G\setminus v$ has a path from $w$ to $u$. This path's length is odd (because it alternates red and blue nodes, so it contains an even number of nodes and an odd number of edges). Together with $u\sim v$ and $v\sim w$ this makes an odd cycle in $G$; contradiction.
So all $v$'s red neighbours are in different components of $G\setminus v$ from $v$'s blue neighbours. So swap the colour of every node in every component containing a blue neighbour of $v$. So now all $v$'s neighbours are red. Colour $v$ blue. Thus $G$ is bipartite; contradiction.
A: (By contradiction)
(->) Suppose n is odd. Let X={ui such that i is odd} and Y={ui such that i is even} as the bipartition formed in the graph. Consider cycle C=u1 u2 u3 u4...un u1 as the cycle in G. If u1 is odd, un can not be odd because there will be no bipartite formed. Therefore, n should be even.
A: One direction is clear. For the other direction you can show this by induction on the number of vertices of $G$.
Suppose $G$ is a graph on $n$ vertices and that it does not contain any odd cycle. Pick a vertex $v$ in $G$ and consider the graph $G\setminus v$. This has $n-1$ vertices and doesn't contain any odd cycle because $G$ doesn't, so it's bipartite by induction hypothesis.
Now let $A$ and $B$ give partition of the bipartite graph $G\setminus v$ and consider where $v$ should go. If all of the neighbours of $v$ are in $A$ (respectively $B$) then put $v$ in $B$ (respectively $A$) to get that $G$ is bipartite. Otherwise let $u \in A $ and $w \in B$ be neighbours of $v$. But then $u$ and $w$ are joined by a path of odd length in $G\setminus v$ by choice of $A$ and $B$ so this path together with the edges $vu$ and $wv$ gives an odd cycle, which is a contradiction.
A: One relatively simple way is to break the if and only if into its two parts:


*

*Prove that if a graph $G$ is bipartite then it has no odd cycles, and

*If $G$ has only even cycles, then you can partition the vertices into two independent sets.


I don't think this is a named theorem, it's too simple.
