continuity of a map on a $T_2$ space Let $X$  be a $T_2$ space .Let $f:X\rightarrow \mathbb R$ be such that $\{(x,f(x):x\in X\}$
is compact.Show that $f$ is continuous
My attempt:
Let $x_n$ be a sequence in $X$ converging to $x$.To show $f$ is continuous we have to show $f(x_n)\rightarrow f(x)$ .Consider $\{(x_n,f(x_n)\}$ which is a compact subset of $X\times \mathbb R$ (Since $X$ and $\mathbb R$ both are $T_2$ so is $X\times \mathbb R$) and hence closed.Thus contains all its limit points.$\{(x_n,f(x_n)\}$ has a convergent subsequence say$\{(x_{n_k},f(x_{n_k})\}$ converging to $(x,y')$(limit is unique since $X$ is $T_2$).Am I proceeding correctly.How to show from here $f(x_n)\rightarrow f(x)$?
 A: Your basic intuition is correct, and if $X$ were a metric space, or even a first countable space, you could show that $f$ is continuous by showing that it preserves limits of convergent sequences, starting off in just this way. Here, though, you know only that $X$ is Hausdorff; that means that its topology isn’t necessarily determined by its convergent sequences, and $f$ might preserve their limits without actually being continuous. This means that you’ll have to use one of the equivalent forms of the actual definition of continuity.
In a metric space the important property of a sequence converging to $x$ is that it eventually gets inside every open nbhd of $x$ and stays there. We can do something like this even without sequences. Suppose that there is a point $x\in X$ such that $f$ is not continuous at $x$; then there is an open nbhd $U$ of $f(x)$ such that whenever $V$ is an open nbhd of $x$, $f[V]\nsubseteq U$. Let $\mathscr{N}$ be the family of open nbhds of $x$; for each $V\in\mathscr{N}$ there is an $x_V\in V$ such that $f(x_V)\notin U$. The collection $\{x_V:V\in\mathscr{N}\}$ gets inside every open nbhd of $x$ and is moreover a place where $f$ behaves ‘badly’ compared with the way it behaves at $x$: if $f$ were continuous at $x$, the points $\{f(x_V):V\in\mathscr{N}\}$ would ‘get close to’ $f(x)$, but here they don’t, since they’re all outside $U$.
For convenience let $G=\{\langle x,f(x)\rangle:x\in X\}$. Since $G$ is compact, and $X\times\Bbb R$ is Hausdorff, you know that $G$ is closed in $X\times\Bbb R$. Let $\pi:X\times\Bbb R\to\Bbb R$ be the projection map; it’s continuous, so $\pi[G]$ is a compact subset of $\Bbb R$; call it $K$. Then $G\subseteq X\times K$. Let $A=\{\langle x_V,f(x_V)\rangle:V\in\mathscr{N}\}$. $A\subseteq G$, and $G$ is closed, so $\operatorname{cl}A\subseteq G$. 


*

*Show that if $(\operatorname{cl}A)\cap(\{x\}\times K)=\varnothing$, then there is a $V\in\mathscr{N}$ such that $A\cap(V\times K)=\varnothing$; you’ll need to use the compactness of $K$. Conclude that there is a $t\in\Bbb R$ such that $\langle x,t\rangle\in\operatorname{cl}A$.  

*Now apply the fact that $\operatorname{cl}A\subseteq G$ and the way the points $x_V$ were chosen to get a contradiction.

A: Without sequences or nets: let $G(f) = \{(x,f(x): x \in X \}$. To show continuity, it suffices to show that for a closed $F \subset \mathbb{R}$, the set $f^{-1}[F]$ is closed.
So assume we have such $F$.
The function $\pi_1: X \times \mathbb{R}, \pi_1(x,y) = x$, is continuous.
The key thing to see is: $$f^{-1}[F] = \pi_1[G(f) \cap (X \times F)]$$
(If $x \in f^{-1}[F]$, then $f(x) \in F$, so $(x,f(x)) \in G(f)$ and also $(x,f(x)) \in X \times F$, and $x = \pi_1(x,f(x))$ is in the right hand side. If $x$ is in the right hand side, there exists, for some $y$, $(x,y) \in G(f) \cap (X \times F)$. But being in $G(f)$ forces $y = f(x)$ and as $y = f(x) \in M$, $x \in f^{-1}[F]$.)
The right hand side is the continuous image of a compact set (the intersection of a closed set $X \times F$ and the compact $G(f)$) so is compact. And as $X$ is Hausdorff, $f^{-1}[F]$ is closed, as required. 
