TITLE: Connectedness in the Quotient Space
QUESTION [5 upvotes]: The problem says this:
Let $\sim$ be an equivalence relation in $X$ and consider the quotient space $X/\sim$. Prove that:

$X$ connected $\Rightarrow$ $X/\sim$ connected.
If $X/\sim$ is connected and every equivalence class $[x] = \left \{ y\in X : y \sim x \right \}$ is connected then $X$ is connected.

Proof 1) is easy and I know how to do it. But I'm stuck in the proof 2). That's what I have tried:
Let's suppose $X$ isn't connected. Then, $X=U\sqcup V$ with $U$ and $V$ open. 
Let $\pi : X\rightarrow X/\sim$ be the application that sends every $x\in X$ into his class. I want to see that $\pi (U)$ and $\pi(V)$ are open and that $\pi (U)\cap\pi (V)= \varnothing$ to conclude that $X/\sim$ isn't connected (because $\pi$ is surjective). But that is absurd, so $X$ must be connected.
I know how to prove that $\pi (U)\cap\pi (V)= \varnothing$, but I don't know how to show that $\pi (U)$ and $\pi(V)$ are open. Any advice?
Thanks!

REPLY [7 votes]: $X$ is connected iff every continuous function $f: X \to
 \{0,1\}$ is constant where $\{0,1\}$ is endowed with the discrete
  topology.

Let $f: X \to\{0,1\}$ be an arbitrary continuous function. Since every equivalence class $[x] = \left \{ y\in X : y \sim x \right \}$ is connected, $f$ restricted to $[x]$ is constant. Then $f$ induces a function $$\displaystyle\tilde f:X/\sim\,\to\{0,1\}$$ such that the following diagram commutes:
$$\require{AMScd}
\def\diaguparrow#1{\smash{
  \raise.6em\rlap{\scriptstyle #1}
  \lower.3em{\mathord{\diagup}}
  \raise.52em{\!\mathord{\nearrow}}
}}
\begin{CD}
&& X/\sim\\
& \diaguparrow{\pi} @VV \\\tilde f V \\
X @>> f> \{0,1\}
\end{CD}$$
that is, $f=\tilde f\circ \pi$. Since $f$ is continuous, $\tilde f$ is continuous. As $X/\sim $ is connected, $\tilde f$ is constant by the above theorem. Hence $f$ is constant.