# Can a nowhere continuous function have a connected graph?

After noticing that function $$f:R→Rf: \mathbb R\rightarrow \mathbb R$$ $$f(x)={sin1xfor x≠00for x=0 f(x) = \left\{\begin{array}{l} \sin\frac{1}{x} & \text{for }x\neq 0 \\ 0 &\text{for }x=0 \end{array}\right.$$
has a graph that is a connected set, despite the function not being continuous at $$x=0x=0$$, I started wondering, doest there exist a function $$f:X→Yf: X\rightarrow Y$$ that is nowhere continuous, but still has a connected graph?

I would like to consider three cases

• $$XX$$ and $$YY$$ being general topological spaces
• $$XX$$ and $$YY$$ being Hausdorff spaces
• ADDED: $$X=Y=RX=Y=\mathbb R$$

But if you have answer for other, more specific cases, they may be interesting too.

Here is an example for $$R2→R\mathbb R^2 \to \mathbb R$$:

$$f(x,y)={ywhen x=0 or x=1xwhen x∈(0,1) and y=01−xwhen x∈(0,1) and y=x(1−x)x(1−x)when x∉{0,1} and y/x(1−x)∉Q0otherwisef(x,y) = \begin{cases} y & \text{when }x=0\text{ or }x=1 \\ x & \text{when }x\in(0,1)\text{ and }y=0 \\ 1-x &\text{when }x\in(0,1)\text{ and } y=x(1-x) \\ x(1-x) & \text{when }x\notin\{0,1\}\text{ and } y/x(1-x) \notin\mathbb Q \\ 0 & \text{otherwise} \end{cases}$$

This is easily seen to be everywhere discontinuous. But its graph is path-connected.

A similar but simpler construction, also $$R2→R\mathbb R^2\to\mathbb R$$:

g(1+rcosθ,rsinθ)=rfor r>0,θ∈Q∩[0,π]g(rcosθ,rsinθ)=rfor r>0,θ∈Q∩[π,2π]g(x,y)=0everywhere else \begin{align} g(1 + r\cos\theta, r\sin\theta) = r & \quad\text{for }r>0,\; \theta\in\mathbb Q\cap[0,\pi] \\ g(r\cos\theta, r\sin\theta) =r & \quad \text{for }r>0,\; \theta\in\mathbb Q\cap[\pi,2\pi] \\ g(x,y) =0 & \quad\text{everywhere else} \end{align}