Why is the graph of a continuous function to a Hausdorff space closed? Say I have two topological spaces given by $(X,\mathscr{T}_X)$ and $(Y,\mathscr{T}_Y)$ where $Y$ is Hausdorff. In addition say I have a function $f:X\rightarrow Y$, and let it be continuous. I want to show that $Gr(f):=\{(x,f(x))\mid x\in X\}$ is a closed subset of $(X\times Y)$. 
In answering this question, could you also provide the "chain of thought" that brought you to the solution. I am aware of what the continuity of the function and the fact that $Y$ is Hausdorff provides me in terms of definition. I am however, finding it hard to find a -link- towards answering the question. Thank you all in advance for your help.
 A: Let $G=\operatorname{Gr}(f)$. In this case the easiest way to show that $G$ is closed in $X\times Y$ is to show that its complement is open, so let $\langle x,y\rangle\in(X\times Y)\setminus G$. Since $\langle x,y\rangle\notin G$, $y\ne f(x)$. Thus, $y$ and $f(x)$ are distinct points in $Y$. And $Y$ is Hausdorff, so there are disjoint open sets $U$ and $V$ in $Y$ such that $y\in U$ and $f(x)\in V$. Finally, $f$ is continuous, so there is an open nbhd $W$ of $x$ such that $f[W]\subseteq V$. 
Up to here I’ve just done what comes naturally: I’ve used the hypotheses in the most obvious way without really thinking about where I’m going. I’m trying to show that $\langle x,y\rangle$ has an open nbhd contained in $(X\times Y)\setminus G$; do I have an open nbhd of $\langle x,y\rangle$ hanging about anywhere? Yes: by definition of the product topology, $W\times U$ is an open nbhd of $\langle x,y\rangle$ in $X\times Y$. If I’m lucky, this nbhd $W\times U$ will turn out to be disjoint from $G$, showing that $\langle x,y\rangle$ is not in the closure of $G$. And since $\langle x,y\rangle$ was an arbitrary point of $(X\times Y)\setminus G$, this would show that $(X\times Y)\setminus G$ is open and hence that $G$ is closed.
Let $\langle z,f(z)\rangle$ be any point of $G$. If $z\notin W$, then clearly $\langle z,f(z)\rangle\notin W\times U$. If $z\in W$, then $f(z)\in V$, so $f(z)\notin U$, and therefore $\langle z,f(z)\rangle\notin W\times U$. Thus, in all cases $\langle z,f(z)\rangle\notin W\times U$, and it follows that $(W\times U)\cap G=\varnothing$. Thus, each point of $(X\times Y)\setminus G$ has an open nbhd disjoint from $G$, and $G$ is therefore closed.
