$G$ has no odd cycles $\iff$ the $X(G)=2$
I already proved the reciprocal but I'm having trouble with this.
Here is my thinking:
Let be $G=(V,E)$. If $G$ has no cycles, then $G$ is a tree so $X(G)=2$ since trees are bipartite.
If $G$ has one cycle, I know it's an even cycle. Let be $C_1=\{v_1,...,v_n\}$ an even cycle of $G$. We can define $k:C_1\rightarrow \{a,b\}$ a coloring of c.
$k(v_1)=a, k(v_2)=b, ... , k(v_n)=b$
Since $k=a$ for odd indexes, $k=b$ for even indexes, and $n$ is even. So $X(C_1)=2$.
But I don't know how affirm that $X(G)=2$. Not to mention $G$ with more than one cycle.
Any help will be appreciated, thanks in advance.