# Continuous function over connected components

Let $X$ be a topological space and $\{C_i\}_{i\in I}$ be the family of its connected components. Now let $A\subseteq I$, define $f:X\rightarrow \mathbb{R}$ by $f(\cup_{i\in A}C_i)=1$ and $f(X\setminus\cup_{i\in A}C_i)=0$. How can we prove that $f$ is continuous

• that's just writing down the definition. Have you tried anything? Aug 24, 2018 at 1:43
• Maybe try it for just two components first Aug 24, 2018 at 1:50

Take $\Bbb Z_p$, the $p$-adic integers, which is totally disconnected, so that the only connected components are the singleton sets $\{p\}$. In this case, your $I$ is in natural correspondence with the space $\Bbb Z_p$ itself. Now let $A=I\setminus\{0\}$, whose union is, of course, the set of nonzero elements of $\Bbb Z_p$. Defining $\,f$ as you have done, we get a function that’s $1$ everywhere but at zero, where $f(0)=0$. Discontinuous, since zero is in the closure of the other set.
(Lots of other totally disconnected spaces would work as well. Like $\Bbb Q$, for instance.)