Is this quotient space connected?

I came across this little problem recently: If \(X\) is a topological space with exactly two components, and given an equivalence relation \(\sim\) what can we say about its quotient space \(X/{\sim}\)? It turns out that \(X/{\sim}\) is connected if and only if there exists \(x,y\in X\) where \(x\) and \(y\) are in separate components, such that \(x\sim y\).

Suppose first that there exists \(x,y\in X\) such that \(x\sim y\). Let \(C_1\) and \(C_2\) be the two components of \(X\) and let \(p: X \to X/{\sim}\) be the natural projection. Since \(p\) is a quotient map it is surely continuous and since the image of a connected space under a continuous function is connected we have have that, say \(p(C_1)\) is connected and so is \(p(C_2)\), but since \(x\sim y\) we have that \(p(C_1)\cap p(C_2)\neq \varnothing\) so \(X/{\sim}\) consists of a single component, becuase \[p(C_1)\cup p(C_2) = p(C_1\cup C_2)=p(X)=X/{\sim},\] as wanted.

To show the reverse implication, we use the contrapositive of the statement and show: if we for no \(x\in C_1\) or \(y\in C_2\) have that \(x\sim y\), then \(X/{\sim}\) is not connected. Assume the hypothesis and note that then \(p(C_1)\) and \(p(C_2)\) are then disjoint connected subspaces whose union equal all of \(X/{\sim}\) (since \(p\) is surjective). But then the images of \(C_1\) and \(C_2\) under \(p\) are two components of \(X/{\sim}\), showing that \(X/{\sim}\) is not connected. As wanted.