Graph of a function homeomorphic to a space implies continuity of the map?

If $X,Y$ are topological spaces and $f: X \rightarrow Y$ is a continuous map then it can be shown that the graph of $f$, $G_{f}$, is homeomorphic to $X$. But is the converse true? That is: if $G_{f} \cong X$ via the map $(x,f(x)) \mapsto x$ is $f$ necessarily a continuous map? I suspect no but haven't had luck with a counterexample. Is this true/false?


This is true. Since $g:X \to G_{f}, \; x \mapsto (x,f(x))$ is in particular continuous and the projection $p: X \times Y \to Y$ is continuous by definition of the product topology, so is the composition $f = p \circ g$.


Added: Concerning the follow-up question whether $f$ is continuous as soon as the graph is homeomorphic to $X$ in some way: The answer is no.

While Brian's construction of a counter-example to this question is very nice and instructive, here's one I find a bit easier to understand. Take $X = \mathbb{Z} \cup \bigcup_{k \in \mathbb{Z}} (k+1/4, k + 3/4)$ with the topology inherited from $\mathbb{R}$. Now define

$$f(x) = \begin{cases}0 & \text{if }x \in \mathbb{Z},\\0 & \text{if }x \in (k+1/4,k+1/2),\\1 & \text{if } x= k + 1/2,\\2 & \text{if }x\in(k+1/2, k+3/4).\end{cases}$$

The graph of $f$ is homeomorphic to a countable union of intervals and countably many points, hence it is homeomorphic to $X$, but $f$ is not continuous, as it fails to be continuous at $x = k + 1/2$.


Let $\hat f:X \to G_f:x \mapsto \langle x,f(x) \rangle$, and assume that $\hat f$ is a homeomorphism. Note that $\hat f^{-1}$ is simply the restriction $p$ of the projection $\pi_X:X \times Y \to X$ to $G_f$, so $p$ is also a homeomorphism. Let $V$ be any open set in $Y$, and let $W = (X \times V) \cap G_f$; $W$ is open in $G_f$, so $p[W]$ is open in $X$. But $p[W] = \hat f^{-1}[W] = f^{-1}[V]$, so $f$ is continuous.

Added: If we do not require that $\hat f$ be the homeomorphism from $X$ to $G_f$, we cannot conclude that $f$ is continuous. Let $X = Y = \mathbb Q$, and enumerate $\mathbb Q = \{q_n:n \in \omega\}$. Let $\mathcal I$ be the set of non-empty open intervals $(p,r)$ in $\mathbb Q$, and enumerate $\mathcal I \times \mathcal I = \{\langle I_0(n),I_1(n) \rangle:n \in \omega \}$. We now recursively construct a function $f:\mathbb Q \to \mathbb Q$ as follows:

  • At stage $n$ let $m \in \omega$ be minimal s.t. $q_m \in I_0(n)$, and let $f(q_m)$ be any rational number in $I_1(n)$.

To see that $f(q)$ is defined for every $q \in \mathbb Q$, suppose not, and let $m \in \omega$ be minimal s.t. $f(q_m)$ is not defined. Each non-empty rational interval $(p,r)$ occurs as $I_0(n)$ for infinitely many $n \in \omega$, so there are infinitely many $n$ s.t. $q_m \in I_0(n)$. In particular, there is a least $n \in \omega$ s.t. $q_m \in I_0(n)$ and all $f(q_k)$ for $k<m$ have been defined by stage $n$, and at this point the construction defines $f(q_m)$.

The construction of $f$ clearly ensures that the point $\langle q_m,f(q_m) \rangle$ chosen at stage $n$ is in $I_0(n) \times I_1(n)$, so $G_f$ is dense in $\mathbb Q \times \mathbb Q$. Thus, $G_f$ is a countable, metrizable space without isolated points and as such is homeomorphic to $\mathbb Q$ with the usual topology, i.e., to $\text{dom }f$. It's also clear that $f$ cannot be continuous, since by construction $\{q \in \mathbb Q:f(q) \in (0,1)\}$ and $\{q \in \mathbb Q:f(q) \in (2,3)\}$ are both dense in $\mathbb Q$.