@VladimirTkachev, in addition to the general case of maps $\ f:X\rightarrow Y,\ $ was also concerned with the special case of $\ Y:=\mathbb R,\ $ i.e. with $\ X\rightarrow\mathbb R.\ $ I'll give an example (negative) in the extra simple case of $\ f:\mathbb I\rightarrow\mathbb R,\ $ where $\ \mathbb I\ $ is a closed interval.
EXAMPLE Let $\ f:[-1;1]\rightarrow\mathbb R\ $ be defined by:
$$\forall_{x\in[-1;1]}\quad f(x) := (x+1)\cdot x\cdot(x-1)$$
Then $\ E(f)\ $ is disconnected. Indeed, $\ (-1\,\ 1)\in E(f)\ $ is an isolated point of $\ E(f).\ $ Of course $\ (1\,\ -\!1)\ $ is another isolated point like this, and there are no other isolated points in $\ E(f)$.
PROOF We have 3 cases:
- if $\ (x\ y)\in E(f)\ $ is such that $\ f(x)=f(y) < 0\ $ then both $\ x\ y>0\ $ are positive;
- $\ E(f)\cap f^{-1}(0)\ =\ \{-1\,\ 0\,\ 1\}^2$
- if $\ (x\ y)\in E(f)\ $ is such that $\ f(x)=f(y) > 0\ $ then both $\ x\ y<0\ $ are negative.
Thus the distance (say, Euclidean) from $\ (-1\,\ 1)\ $ or $\ (1\,\ -\!1)\ $ to any other point $\ (x\ y)\in E(f)\ $ is at least $\ 1$.
End of PROOF
(I'll add some comments/extensions).