Let $X$ and $Y$ be topological spaces and $f:X\to Y$. The graph of $f$ is the subset $G=\{(x,f(x))\}\subseteq X\times Y$. Show that if $f$ is continuous, then $X$ is homeomorphic to the graph of $f$.
My attempt: Let $h:X\to G$ by $h(x)=(x,f(x))$. The fact that $h$ is a bijection is clear. Now since $g:X\to X$ by $g(x)=x$ is continuous and $f:X\to Y$ is continuous by hypothesis, the universal mapping property of products says that $h$ must be continuous. I'm having trouble showing $h^{-1}$ is continuous though... $g^{-1}:X\to X$ is continuous by the same argument as for $g$, but how would I show that $f^{-1}$ is continuous?