Let $X,d$ be a metric space .Let $f:X\to \mathbb R$ be a continuous function.Define $G(f)=\{(x,f(x)):x\in X\}$.

Prove that $G(f)$ is homeomorphic to $X$.

**My try**:

Since $f$ is continuous then $G(f)$ is a closed set. To define a homeomorphism we need a mapping $g:G(f)\to X$ .Can $g$ be defined as $g((x,f(x))=x$?i.e the projection map.

To check $g$ is a homeomorphism:

Let $U$ be closed in $X$.to show $g^{-1}(U)$ is closed in $G(f)$.Now $g^{-1}(U)=U\times f(U)$ how to show it is closed in $G(f)$??

Next to show that $g$ is a closed map.How to proceed here?

It will be great if someone could check if it is so.